A data structure that can hold a set of unique Python objects, even if those objects are not hashable. Uniqueness is determined based upon identity.

object_set classes


class graphtage.object_set.IdentityHash(obj)

Bases: object



class graphtage.object_set.ObjectSet(initial_objs: Iterable[Any] = ())

Bases: MutableSet

A set that can hold unhashable Python objects

Uniqueness is determined based upon identity.

__init__(initial_objs: Iterable[Any] = ())
classmethod _from_iterable(it)

Construct an instance of the class from any iterable input.

Must override this method if the class constructor signature does not accept an iterable for an input.


Compute the hash value of a set.

Note that we don’t define __hash__: not all sets are hashable. But if you define a hashable set type, its __hash__ should call this function.

This must be compatible __eq__.

All sets ought to compare equal if they contain the same elements, regardless of how they are implemented, and regardless of the order of the elements; so there’s not much freedom for __eq__ or __hash__. We match the algorithm used by the built-in frozenset type.


Add an element.


This is slow (creates N new iterators!) but effective.


Remove an element. Do not raise an exception if absent.


Return True if two sets have a null intersection.


Return the popped value. Raise KeyError if empty.


Remove an element. If not a member, raise a KeyError.