def __eq__(self, E): # overloads ==
        """
        Returns the equality comparison of DS with E typed
        as a DictSet. If E cannot be broadcast into a DictSet
        returns False.

        DS==E  <==> DS.__eq__(E)
        """
        # Fails of d is not mappable with iterable values
        try:
            E = DictSet(E)
        except:
            return False

        # check to see if self and E have the same keys
        # if they don't we know they aren't equal and
        # can return False
        if len(set(k for (k, v) in self.items() if len(v) != 0)  ^
               set(k for (k, v) in    E.items() if len(v) != 0)) > 0:
            return False

        # at this point we know they have the same keys
        # if all the non-empty set differences have 0 cardinality
        # the sets are equal
        s = 0
        for k in self.keys():
            s += len(self.get(k, []) ^ E.get(k, []))
        return s == 0

        Returns the equality comparison of DS with E typed
        as a DictSet. If E cannot be broadcast into a DictSet
        returns False.

        DS==E  <==> DS.__eq__(E)
        
recipes/Python/577702_DictSet__specialized_Pythcontainer_datatype/recipe-577702.py