Registry / serialization / dict-hash

dict-hash

JSON →
library1.3.7pypypi✓ verified 86d ago

Python package to hash dictionaries using default hash, md5, sha256 and more. Supports nested structures, pandas, numpy, polars, datetime, and custom hash functions. Active development with recent additions including approximate hashing and support for timedelta. Current version: 1.3.7.

pip install dict-hash
INSTALL
IMPORT
SIG · DICT-HASH
D
dict-hash
serializationpythonv1.3.7
Install
3.1s avg
Import
43ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.044s · 19.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.1s · import 0.042s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sha256
from dict_hash import sha256
Direct function import for SHA256 hashing

Compute a SHA256 hash of a dictionary.

from dict_hash import sha256 my_dict = {"a": 1, "b": [2, 3], "c": {"d": "text"}} hash_value = sha256(my_dict) print(hash_value) # Example: b"..."
Debug
Known issues
gotchaThe library does not guarantee deterministic hashing across different Python versions (e.g., default hash seeds). Use sha256 or another cryptographic hash for consistency.
fix
Use 'sha256' or 'md5' instead of 'dict_hash' for a stable hash.
affects: all
breakingVersion 1.3.0 changed the handling of NumPy objects; older code may produce different hashes if pandas is not installed.
fix
Ensure pandas is installed if you hash dictionaries containing pandas objects, or update code to handle NumPy-only dicts separately.
affects: >=1.3.0
deprecatedThe 'hash_func' parameter in earlier versions is deprecated; use named functions like 'sha256' instead.
fix
Replace 'dict_hash(my_dict, hash_func='sha256')' with 'from dict_hash import sha256; sha256(my_dict)'.
affects: <1.3.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'dict_hash'
Package not installed or installed as 'dict-hash' but imported incorrectly.
fix
Install with 'pip install dict-hash' and import using 'from dict_hash import ...'.
ValueError: Invalid hash algorithm: md5
In older versions, hash function names were not exported; direct use of string names may fail.
fix
Update to latest version and use 'from dict_hash import md5' then call 'md5(my_dict)'.
TypeError: Object of type DataFrame is not JSON serializable
Trying to hash a pandas DataFrame without pandas support installed or using a custom serializer.
fix
Install pandas: 'pip install pandas'. Then use 'from dict_hash import sha256; sha256(my_dict)'.
Upgrade
Version history
1.3.7latest on PyPI · released Nov 10, 2025
Audit
Dependencies
numpyoptionalRequired for hashing numpy arrays
pandasoptionalRequired for hashing pandas DataFrames/Series
polarsoptionalRequired for hashing polars DataFrames/Series
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
dict-hash — pip install dict-hash · libregistry