Message370956
What about returning another dict_items instead of a set? As in (using the convention `d.items().mapping is d`):
dict_items = type({}.items())
def __xor__(self: dict_items, other):
if isinstance(other, dict_items):
new = self.mapping.copy()
MISSING = object()
for key, value in other:
existing = new.get(key, MISSING)
if existing is MISSING:
# (key, value) in (other - self)
new[key] = value
elif existing == value:
# (key, value) in (self & other)
del new[key]
else:
# (key, value) in (self - other)
new[key] = value
return new.items()
else:
return set(self) ^ set(other)
I believe this wouldn't require any re-hashing. It would also allow for non-hashable values. |
|
Date |
User |
Action |
Args |
2020-06-08 04:36:28 | Dennis Sweeney | set | recipients:
+ Dennis Sweeney, rhettinger, serhiy.storchaka |
2020-06-08 04:36:28 | Dennis Sweeney | set | messageid: <1591590988.84.0.110440982112.issue40889@roundup.psfhosted.org> |
2020-06-08 04:36:28 | Dennis Sweeney | link | issue40889 messages |
2020-06-08 04:36:28 | Dennis Sweeney | create | |
|