hash the unhashable, hash everything
Project description
What is this?
A simple python tool for hashing objects that python normally treats as unhashable. There are also a few other tools such as ways of deeply hashing functions, and an system for extending this hashability to work with other existing classes, such as dataframes or neural networks.
How do I use this?
pip install super_hash
from super_hash import super_hash, function_hashers, FrozenDict, helpers
normally_unhashable = {
frozenset({
frozenset({
"key-deep-deep": 10
}.items()): "key-deep",
}.items()): "first_value",
"second_value": [
{"a": 10},
]
}
a_hash = super_hash(normally_unhashable)
#
# extend what can be hashed
#
# example1:
import pandas as pd
# tell super_hash that pandas dataframes should be converted to csv, then hashed
super_hash.conversion_table[pd.DataFrame] = lambda data_frame : super_hash(data_frame.to_csv())
# example2:
import torch
# create a custom checker function
is_non_scalar_pytorch_tensor = lambda value: isinstance(value, torch.Tensor) and len(value.shape) > 0
# create a custom converter
super_hash.conversion_table[is_non_scalar_pytorch_tensor] = lambda non_scalar_tensor: super_hash(non_scalar_tensor.tolist())
# example3:
class Thing:
def __super_hash__(self):
return self.file_path
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file super_hash-1.4.0.tar.gz.
File metadata
- Download URL: super_hash-1.4.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b65716b41f21587e968021fd1e9f984add347d8ab75b9b0b715362f2b923179a
|
|
| MD5 |
05f86a24c26c4783c84fac7d7d33d0e3
|
|
| BLAKE2b-256 |
2b04410d3b4b1863bef203848808476233c915f81d37f312eeac6ad664853278
|
File details
Details for the file super_hash-1.4.0-py3-none-any.whl.
File metadata
- Download URL: super_hash-1.4.0-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8921cd154ef45113d443b06c95b6fd4b93629782564ed51408b8701e42116675
|
|
| MD5 |
2f95251036b31b1a5f8b46f84c729db5
|
|
| BLAKE2b-256 |
6216de9ac42e3d5cecf98c4f88629cf88a5daf47cb34c8ca71ad95f708931001
|