{"id":599,"library":"xxhash","title":"xxHash Python Binding","description":"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.","status":"active","version":"3.6.0","language":"python","source_language":"en","source_url":"https://github.com/ifduyue/python-xxhash","tags":["hashing","checksum","performance","utility","non-cryptographic"],"install":[{"cmd":"pip install xxhash","lang":"bash","label":"Install stable release"}],"dependencies":[],"imports":[{"symbol":"xxhash","correct":"import xxhash"},{"note":"Used for 64-bit hashing. For incremental hashing, initialize with `xxhash.xxh64()` then use `.update(data)`.","symbol":"xxh64","correct":"xxhash.xxh64(data)"},{"note":"Introduced in v2.0.0. Provides improved performance and distribution. Also has incremental use.","symbol":"xxh3_64","correct":"xxhash.xxh3_64(data)"},{"note":"Introduced in v2.0.0. Provides a 128-bit hash.","symbol":"xxh3_128","correct":"xxhash.xxh3_128(data)"}],"quickstart":{"code":"import xxhash\n\ndata_to_hash = b\"Hello, xxHash! This is some data to be hashed.\"\n\n# One-shot hashing\nhash_value_64 = xxhash.xxh64(data_to_hash, seed=0).hexdigest()\nhash_value_128 = xxhash.xxh3_128(data_to_hash).hexdigest()\n\nprint(f\"XXH64 Hash: {hash_value_64}\")\nprint(f\"XXH3_128 Hash: {hash_value_128}\")\n\n# Incremental hashing\nhasher = xxhash.xxh64(seed=42)\nhasher.update(b\"First chunk \")\nhasher.update(b\"of data.\")\nincremental_hash = hasher.hexdigest()\nprint(f\"Incremental XXH64 Hash: {incremental_hash}\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade to Python 3.7+ or pin `xxhash<3.3.0`.","message":"Python 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.","severity":"breaking","affected_versions":">=3.3.0"},{"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.","message":"`xxhash` v2.0.0 introduced XXH3 hashes (`xxh3_64`, `xxh3_128`) and required the underlying xxHash C library version 0.8.0 or newer.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Avoid using `xxhash.VERSION_TUPLE`. Use `xxhash.VERSION` for the module version string.","message":"`xxhash.VERSION_TUPLE` has been deprecated in v3.6.0 and will be removed in the next major release.","severity":"deprecated","affected_versions":">=3.6.0"},{"fix":"Use cryptographic hash functions (e.g., from Python's `hashlib` module) for security-sensitive contexts.","message":"xxHash 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.","severity":"gotcha","affected_versions":"all"},{"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).","message":"The `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.","severity":"gotcha","affected_versions":"all"},{"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.","message":"As 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.","severity":"breaking","affected_versions":"<0.3.0 to >=0.3.0"}],"env_vars":null,"last_verified":"2026-05-12T16:26:13.973Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"pip install xxhash","cause":"The xxhash library is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'xxhash'"},{"fix":"Encode the string to bytes before hashing, for example: `xxhash.xxh64('hello world'.encode('utf-8'))`","cause":"The xxhash hashing functions expect byte-like objects (e.g., `bytes`), but a Python string was provided directly.","error":"TypeError: a bytes-like object is required, not 'str'"},{"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.","cause":"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.","error":"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/"},{"fix":"Call `xxh64()` with the data to get a hasher instance, then call `hexdigest()` on that instance: `xxhash.xxh64(b'data').hexdigest()`","cause":"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.","error":"AttributeError: type object 'xxhash.xxh64' has no attribute 'hexdigest'"}],"ecosystem":"pypi","meta_description":null,"install_score":80,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"3.7.0","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"18.3M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"18.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0,"mem_mb":0,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"20.2M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"20.2M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0,"mem_mb":0,"disk_size":"21M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"12.0M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"12.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0,"mem_mb":0,"disk_size":"13M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"13M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.8M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0,"mem_mb":0,"disk_size":"13M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"17.8M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"17.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.9,"import_time_s":0,"mem_mb":0,"disk_size":"19M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}