This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dennis Sweeney
Recipients Dennis Sweeney, rhettinger, serhiy.storchaka
Date 2020-06-08.04:36:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591590988.84.0.110440982112.issue40889@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-06-08 04:36:28Dennis Sweeneysetrecipients: + Dennis Sweeney, rhettinger, serhiy.storchaka
2020-06-08 04:36:28Dennis Sweeneysetmessageid: <1591590988.84.0.110440982112.issue40889@roundup.psfhosted.org>
2020-06-08 04:36:28Dennis Sweeneylinkissue40889 messages
2020-06-08 04:36:28Dennis Sweeneycreate