lisa.utils.SimpleHash#

class lisa.utils.SimpleHash[source]#

Bases: object

Base class providing a basic implementation of __eq__ and __hash__: two instances are equal if their __dict__ and __class__ attributes are equal.

Methods

HASH_COERCE()

Used to coerce the values of self.__dict__ to hashable values.

Methods#

SimpleHash.HASH_COERCE(x, coerce)[source]#

Used to coerce the values of self.__dict__ to hashable values.

Parameters:
  • x (object) – the value to coerce to a hashable value

  • coerce (collections.abc.Callable) –

    Function to be used to recurse, rather than self.HASH_COERCE. This takes care of memoization to avoid infinite recursion.

    Attention

    The coerce function should only be called on values that will be alive after the call has ended, i.e. it can only be passed parts of the x structure. If temporary objects are passed, memoization will not work as it relies on id(), which is only guaranteed to provide unique ID to objects that are alive.