simpleml.persistables.hashing module

Mixin classes to handle hashing

class simpleml.persistables.hashing.CustomHasherMixin[source]

Bases: object

Mixin class to hash any object

custom_hasher(object_to_hash, custom_class_proxy=<class 'mappingproxy'>)[source]

Adapted from: https://stackoverflow.com/questions/5884066/hashing-a-dictionary Makes a hash from a dictionary, list, tuple or set to any level, that contains only other hashable types (including any lists, tuples, sets, and dictionaries). In the case where other kinds of objects (like classes) need to be hashed, pass in a collection of object attributes that are pertinent. For example, a class can be hashed in this fashion:

custom_hasher([cls.__dict__, cls.__name__])

A function can be hashed like so:

custom_hasher([fn.__dict__, fn.__code__])