simpleml._external.joblib
Copied from joblib library – no modification, just avoiding unnecessary dependencies https://github.com/joblib/joblib/blob/master/joblib/hashing.py#L246
Fast cryptographic hash of Python objects, with a special case for fast hashing of numpy arrays.
Module Contents
Classes
A subclass of pickler, to do cryptographic hashing, rather than |
|
Special case the hasher for when numpy is loaded. |
|
Class used to ensure the hash of Sets is preserved |
|
Class used to hash objects that won't normally pickle |
Functions
|
Quick calculation of a hash to identify uniquely Python objects |
Attributes
- class simpleml._external.joblib.Hasher(hash_name='md5')[source]
Bases:
Pickler
A subclass of pickler, to do cryptographic hashing, rather than pickling.
This takes a binary file for writing a pickle data stream.
The optional protocol argument tells the pickler to use the given protocol; supported protocols are 0, 1, 2, 3 and 4. The default protocol is 3; a backward-incompatible protocol designed for Python 3.
Specifying a negative protocol version selects the highest protocol version supported. The higher the protocol used, the more recent the version of Python needed to read the pickle produced.
The file argument must have a write() method that accepts a single bytes argument. It can thus be a file object opened for binary writing, an io.BytesIO instance, or any other custom object that meets this interface.
If fix_imports is True and protocol is less than 3, pickle will try to map the new Python 3 names to the old module names used in Python 2, so that the pickle data stream is readable with Python 2.
- class simpleml._external.joblib.NumpyHasher(hash_name='md5', coerce_mmap=False)[source]
Bases:
Hasher
Special case the hasher for when numpy is loaded.
- hash_name: string
The hash algorithm to be used
- coerce_mmap: boolean
Make no difference between np.memmap and np.ndarray objects.
- class simpleml._external.joblib._ConsistentSet(set_sequence)[source]
Bases:
object
Class used to ensure the hash of Sets is preserved whatever the order of its items.
- class simpleml._external.joblib._MyHash(*args)[source]
Bases:
object
Class used to hash objects that won’t normally pickle
- simpleml._external.joblib.hash(obj, hash_name='md5', coerce_mmap=False)[source]
Quick calculation of a hash to identify uniquely Python objects containing numpy arrays. Parameters ———– hash_name: ‘md5’ or ‘sha1’
Hashing algorithm used. sha1 is supposedly safer, but md5 is faster.
- coerce_mmap: boolean
Make no difference between np.memmap and np.ndarray