graphtage.object_set

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

IdentityHash

class graphtage.object_set.IdentityHash(obj)

Bases: object

__init__(obj)

ObjectSet

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.

_hash()

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(value)

Add an element.

clear()

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

discard(value)

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

isdisjoint(other)

Return True if two sets have a null intersection.

pop()

Return the popped value. Raise KeyError if empty.

remove(value)

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