autointent.Hasher#

class autointent.Hasher#

A class that provides methods for hashing data using xxhash.

This class supports both a class-level method for generating hashes from any given value, as well as an instance-level method for progressively updating a hash state with new values. We use this class for hashing embeddings from autointent.Embedder.

classmethod hash(value)#

Generate a hash for the given value using xxhash.

Parameters:

value (Any) – The value to be hashed. This can be any Python object.

Returns:

The resulting hash digest as a hexadecimal string.

Return type:

int

update(value)#

Update the internal hash state with the provided value.

This method will first hash the type of the value, then hash the value itself, and update the internal state accordingly.

Parameters:

value (Any) – The value to be hashed and added to the internal state.

Return type:

None

hexdigest()#

Return the current hash digest as a hexadecimal string.

This method should be called after one or more update calls to get the final hash result.

Returns:

The resulting hash digest as a hexadecimal string.

Return type:

str

intdigest()#

Return the current hash digest as an integer.

This method should be called after one or more update calls to get the final hash result.

Returns:

The resulting hash digest as an integer.

Return type:

int