idmtools.utils.hashing module#
Fast hash of Python objects.
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
- class idmtools.utils.hashing.Hasher(hash_name='md5')[source]#
Bases:
_Pickler
A subclass of pickler to do hashing, rather than pickling.
- __init__(hash_name='md5')[source]#
Initialize our hasher.
- Parameters:
hash_name – Hash type to use. Defaults to md5
- hash(obj, return_digest=True)[source]#
Hash an object.
- Parameters:
obj – Object to hash
return_digest – Should the digest be returned?
- Returns:
None if return_digest is False, otherwise the hash digest is returned
- idmtools.utils.hashing.hash_obj(obj, hash_name='md5')[source]#
Quick calculation of a hash to identify uniquely Python objects.
- Parameters:
obj – Object to hash
hash_name – The hashing algorithm to use. ‘md5’ is faster; ‘sha1’ is considered safer.
- idmtools.utils.hashing.ignore_fields_in_dataclass_on_pickle(item)[source]#
Ignore certain fields for pickling on dataclasses.
- Parameters:
item – Item to pickle
- Returns:
State of item to pickle