# 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`
```python
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
```
Raw data
{
"_id": null,
"home_page": "https://github.com/jeff-hykin/super_hash.git",
"name": "super-hash",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "Jeff Hykin",
"author_email": "jeff.hykin@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2b/04/410d3b4b1863bef203848808476233c915f81d37f312eeac6ad664853278/super_hash-1.4.0.tar.gz",
"platform": null,
"description": "# What is this?\n\nA 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.\n\n# How do I use this?\n\n`pip install super_hash`\n\n\n```python\nfrom super_hash import super_hash, function_hashers, FrozenDict, helpers\n\nnormally_unhashable = {\n frozenset({\n frozenset({\n \"key-deep-deep\": 10\n }.items()): \"key-deep\",\n }.items()): \"first_value\",\n \"second_value\": [\n {\"a\": 10},\n ]\n}\na_hash = super_hash(normally_unhashable)\n\n# \n# extend what can be hashed\n# \n\n# example1:\nimport pandas as pd\n# tell super_hash that pandas dataframes should be converted to csv, then hashed\nsuper_hash.conversion_table[pd.DataFrame] = lambda data_frame : super_hash(data_frame.to_csv())\n\n# example2:\nimport torch\n# create a custom checker function\nis_non_scalar_pytorch_tensor = lambda value: isinstance(value, torch.Tensor) and len(value.shape) > 0\n# create a custom converter\nsuper_hash.conversion_table[is_non_scalar_pytorch_tensor] = lambda non_scalar_tensor: super_hash(non_scalar_tensor.tolist())\n\n# example3:\nclass Thing:\n def __super_hash__(self):\n return self.file_path\n```\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "hash the unhashable, hash everything",
"version": "1.4.0",
"project_urls": {
"Homepage": "https://github.com/jeff-hykin/super_hash.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6216de9ac42e3d5cecf98c4f88629cf88a5daf47cb34c8ca71ad95f708931001",
"md5": "2f95251036b31b1a5f8b46f84c729db5",
"sha256": "8921cd154ef45113d443b06c95b6fd4b93629782564ed51408b8701e42116675"
},
"downloads": -1,
"filename": "super_hash-1.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2f95251036b31b1a5f8b46f84c729db5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 20009,
"upload_time": "2023-12-04T20:50:23",
"upload_time_iso_8601": "2023-12-04T20:50:23.521397Z",
"url": "https://files.pythonhosted.org/packages/62/16/de9ac42e3d5cecf98c4f88629cf88a5daf47cb34c8ca71ad95f708931001/super_hash-1.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2b04410d3b4b1863bef203848808476233c915f81d37f312eeac6ad664853278",
"md5": "05f86a24c26c4783c84fac7d7d33d0e3",
"sha256": "b65716b41f21587e968021fd1e9f984add347d8ab75b9b0b715362f2b923179a"
},
"downloads": -1,
"filename": "super_hash-1.4.0.tar.gz",
"has_sig": false,
"md5_digest": "05f86a24c26c4783c84fac7d7d33d0e3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 18827,
"upload_time": "2023-12-04T20:50:27",
"upload_time_iso_8601": "2023-12-04T20:50:27.367551Z",
"url": "https://files.pythonhosted.org/packages/2b/04/410d3b4b1863bef203848808476233c915f81d37f312eeac6ad664853278/super_hash-1.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-04 20:50:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jeff-hykin",
"github_project": "super_hash",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "super-hash"
}