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
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 thex
structure. If temporary objects are passed, memoization will not work as it relies onid()
, which is only guaranteed to provide unique ID to objects that are alive.