Registry / serialization / xxhash

xxhash

JSON →
library4.0.1pypypi✓ verified 29d ago

xxhash is a Python binding for the high-performance, non-cryptographic xxHash library by Yann Collet. It is widely favored for its speed and efficiency in applications requiring fast hashing of large volumes of data, such as data integrity checks, file deduplication, and checksum generation. The library is actively maintained, with version 3.6.0 currently available, and new releases occurring a few times a year, often to support newer Python versions and xxHash upstream updates.

pip install xxhash
INSTALL
IMPORT
SIG · XXHASH
X
xxhash
serializationpythonv4.0.1
Install
1.9s avg
Import
—
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.0.1 · 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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.5MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

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

xxhash
✓ import xxhash
xxh64
✓ xxhash.xxh64(data)
Used for 64-bit hashing. For incremental hashing, initialize with `xxhash.xxh64()` then use `.update(data)`.
xxh3_64
✓ xxhash.xxh3_64(data)
Introduced in v2.0.0. Provides improved performance and distribution. Also has incremental use.
xxh3_128
✓ xxhash.xxh3_128(data)
Introduced in v2.0.0. Provides a 128-bit hash.

This example demonstrates both one-shot and incremental hashing using the `xxh64` and `xxh3_128` algorithms. Data must be provided as bytes. An optional seed can be used to generate distinct hash outputs for identical input data.

import xxhash data_to_hash = b"Hello, xxHash! This is some data to be hashed." # One-shot hashing hash_value_64 = xxhash.xxh64(data_to_hash, seed=0).hexdigest() hash_value_128 = xxhash.xxh3_128(data_to_hash).hexdigest() print(f"XXH64 Hash: {hash_value_64}") print(f"XXH3_128 Hash: {hash_value_128}") # Incremental hashing hasher = xxhash.xxh64(seed=42) hasher.update(b"First chunk ") hasher.update(b"of data.") incremental_hash = hasher.hexdigest() print(f"Incremental XXH64 Hash: {incremental_hash}")
Debug
Known issues
breakingPython 3.6 support was dropped in `xxhash` v3.3.0. Users on Python 3.6 or older must use `xxhash` v3.2.0 or earlier.
fix
Upgrade to Python 3.7+ or pin `xxhash<3.3.0`.
affects: >=3.3.0
breaking`xxhash` v2.0.0 introduced XXH3 hashes (`xxh3_64`, `xxh3_128`) and required the underlying xxHash C library version 0.8.0 or newer.
fix
Ensure your environment or bundled C library meets the version requirement if building from source. For new code, consider using XXH3 algorithms for better performance.
affects: >=2.0.0
deprecated`xxhash.VERSION_TUPLE` has been deprecated in v3.6.0 and will be removed in the next major release.
fix
Avoid using `xxhash.VERSION_TUPLE`. Use `xxhash.VERSION` for the module version string.
affects: >=3.6.0
gotchaxxHash is a non-cryptographic hash function designed for speed and is NOT suitable for security-critical applications like password hashing, digital signatures, or HMAC where collision resistance is paramount.
fix
Use cryptographic hash functions (e.g., from Python's `hashlib` module) for security-sensitive contexts.
affects: all
gotchaThe `seed` argument for `xxh32` and `xxh64` functions expects an unsigned 32-bit or 64-bit integer, respectively. Providing a negative value or an overly large integer can lead to unexpected behavior.
fix
Ensure the `seed` value is a non-negative integer within the valid range for the chosen hash function (0 to 2^32-1 for xxh32, 0 to 2^64-1 for xxh64).
affects: all
breakingAs of `xxhash` v0.3.0, the `digest()` method returns bytes in big-endian representation of the integer hash. Prior versions returned little-endian, which is a breaking change for compatibility if upgrading from very old versions.
fix
If migrating from a pre-0.3.0 version and relying on `digest()` byte order, update logic to expect big-endian. For new code, this is the default and expected behavior.
affects: <0.3.0 to >=0.3.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'xxhash'
The xxhash library is not installed in the current Python environment.
fix
pip install xxhash
TypeError: a bytes-like object is required, not 'str'
The xxhash hashing functions expect byte-like objects (e.g., `bytes`), but a Python string was provided directly.
fix
Encode the string to bytes before hashing, for example: `xxhash.xxh64('hello world'.encode('utf-8'))`
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
Installing the `xxhash` Python package on Windows requires a C++ compiler to build its C extension, but the necessary Visual C++ Build Tools are not installed.
fix
Download and install the "Build Tools for Visual Studio" from the provided link, ensuring the "Desktop development with C++" workload or just the C++ build tools are selected during installation.
AttributeError: type object 'xxhash.xxh64' has no attribute 'hexdigest'
The `hexdigest` or `intdigest` method was called on the `xxh64` class itself, rather than on an instance of the hasher object returned by calling `xxh64()` with data.
fix
Call `xxh64()` with the data to get a hasher instance, then call `hexdigest()` on that instance: `xxhash.xxh64(b'data').hexdigest()`
Upgrade
Version history
4.0.1latest on PyPI · released Aug 17, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources