def __eq__(self, other): if self is other: return True if not isinstance( # pylint: disable=isinstance-second-argument-not-valid-type other, AbstractSet): return NotImplemented return _PySet.__eq__(self, other)
def __hash__(self): """Compute the hash value of a frozenbag.""" if not hasattr(self, '_hash_value'): self._hash_value = Set._hash(self) return self._hash_value
__and__ = Set.__and__ __or__ = Set.__or__ __sub__ = Set.__sub__ __xor__ = Set.__xor__ issubset = __le__ issuperset = __ge__ union = __or__ intersection = __and__ difference = __sub__ symmetric_difference = __xor__ isdisjoint = Set.isdisjoint Set.register(PSet) Hashable.register(PSet) _EMPTY_PSET = PSet(pmap()) def pset(iterable=(), pre_size=8): """ Creates a persistent set from iterable. Optionally takes a sizing parameter equivalent to that used for :py:func:`pmap`. >>> s1 = pset([1, 2, 3, 2]) >>> s1 pset([1, 2, 3]) """ if not iterable:
#MappingView.register(EmptyMapping) KeysView.register(EmptySet) ItemsView.register(EmptySet) ValuesView.register(EmptyCollection) assert issubclass(EmptySet, KeysView) assert issubclass(EmptySet, ItemsView) assert issubclass(EmptySet, Set) assert issubclass(EmptySet, MappingView) assert issubclass(EmptyCollection, ValuesView) assert issubclass(EmptyCollection, Collection) assert issubclass(EmptyCollection, MappingView) Mapping.register(EmptyMapping) Set.register(EmptySet) Sequence.register(EmptySequence) assert issubclass(EmptyMapping, Mapping) assert issubclass(EmptySet, Set) assert issubclass(EmptySequence, Sequence) if 0: Mapping.register(EmptyThree) Set.register(EmptyThree) Sequence.register(EmptyThree) assert issubclass(EmptyThree, Mapping) assert issubclass(EmptyThree, Set) assert issubclass(EmptyThree, Sequence)
def __hash__(self): return Set._hash(self)