Registry / serialization / murmurhash

murmurhash

JSON →
library1.0.15pypypi✓ verified 24d ago

MurmurHash is a fast, non-cryptographic hash function library, primarily used for tasks like hash table indexing, data deduplication, and probabilistic data structures. This Python library provides efficient Cython bindings for MurmurHash, offering various 32-bit and 128-bit hash variants. It is actively maintained with frequent updates to support new Python versions and architectures.

pip install murmurhash
INSTALL
IMPORT
SIG · MURMURHASH
M
murmurhash
serializationpythonv1.0.15
Install
1.6s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.15 · 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.000s · 18.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.004s · 19MB
16MB installed
● package 16MB
Code
Verified usage

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

hash
import murmurhash.mrmr murmurhash.mrmr.hash('data')
import mmh3
This library (explosion/murmurhash) is distinct from the popular `mmh3` package, which has a different import path and API. Ensure you are using the correct library for your needs.
hash64
import murmurhash.mrmr murmurhash.mrmr.hash64('data')
Provides a 64-bit MurmurHash output.
hash128
import murmurhash.mrmr murmurhash.mrmr.hash128('data')
Provides a 128-bit MurmurHash output as a tuple of two integers.

Demonstrates basic usage of `murmurhash.mrmr.hash`, `hash64`, and `hash128` functions with string and bytes input, and explicit seed values. Strings are UTF-8 encoded by default.

import murmurhash.mrmr # Hash a string (UTF-8 encoded by default) text_hash = murmurhash.mrmr.hash('hello world', seed=42) print(f"32-bit hash for 'hello world': {text_hash}") # Hash bytes bytes_hash = murmurhash.mrmr.hash(b'hello world', seed=42) print(f"32-bit hash for b'hello world': {bytes_hash}") # Get a 64-bit hash hash_64 = murmurhash.mrmr.hash64('another example', seed=0) print(f"64-bit hash: {hash_64}") # Get a 128-bit hash (returns a tuple of two integers) hash_128 = murmurhash.mrmr.hash128('long string data', seed=12345) print(f"128-bit hash: {hash_128}") # Example with environment variable for seed (not typical for hash, but for auth template) # import os # seed_from_env = int(os.environ.get('MURMURHASH_SEED', '0')) # env_hash = murmurhash.mrmr.hash('secure_data', seed=seed_from_env) # print(f"Hash with env seed: {env_hash}")
Debug
Known issues
breakingBe aware that `murmurhash` (from `explosion`) is a distinct package from the widely used `mmh3` library for MurmurHash3. They have different import paths (`import murmurhash.mrmr` vs `import mmh3`) and potentially different API behaviors. Installing one and attempting to use the other's API will lead to `ImportError` or unexpected hash results.
fix
Ensure you `pip install murmurhash` and `import murmurhash.mrmr` for this library, or `pip install mmh3` and `import mmh3` if you intend to use the `mmh3` library. Always refer to the specific library's documentation for correct API usage.
affects: All versions
gotchaStarting from version 1.0.7, MurmurHash2 and MurmurHash3 implementations within this library were made endian-neutral. While this ensures consistent hash values across diverse system architectures (e.g., big-endian vs. little-endian), it may produce different hash outputs compared to older `murmurhash` versions or other MurmurHash implementations that are endian-sensitive.
fix
If comparing hash values with systems using older versions or different MurmurHash implementations, verify their endian-neutrality. For strict compatibility with older, endian-sensitive MurmurHash outputs, manual endian handling might be necessary, or consider pinning to an older `murmurhash` version if acceptable.
affects: 1.0.7 and later
gotchaMurmurHash is a non-cryptographic hash function optimized for speed and good distribution, not for security. It should not be used for cryptographic purposes such as password hashing, digital signatures, or data integrity where collision resistance and unpredictability are critical. Always use a consistent `seed` value to ensure reproducible hash outputs, especially when relying on hashes for data partitioning, caching, or lookups across different systems or application runs.
fix
For security-sensitive applications, use cryptographic hash functions from Python's `hashlib` module (e.g., `hashlib.sha256`). For consistent non-cryptographic hashing, explicitly pass the `seed` argument to `murmurhash.mrmr.hash()` (or `murmurhash.mrmr.hash_bytes()` for byte strings). Note that `murmurhash.mrmr` primarily provides 32-bit MurmurHash3. If 64-bit or 128-bit MurmurHash implementations are required, consider using alternative libraries such as `mmh3` or `pyfarmhash` which explicitly offer these functionalities, or ensure all parts of your system use the same default seed.
affects: All versions
Errors
Common errors & fixes
ERROR: Command errored out with exit status 1: ... Running setup.py install for murmurhash: finished with status 'error'
This error typically occurs during installation when the Cython extensions for `murmurhash` cannot be compiled, often due to missing build tools (like `gcc` on Linux or C++ build tools on Windows) or an incompatible environment (e.g., specific Linux distributions like Alpine).
fix
Ensure you have the necessary C/C++ compilers installed on your system. On Debian/Ubuntu: `sudo apt-get update && sudo apt-get install build-essential python3-dev`. On Windows, install 'Desktop development with C++' from Visual Studio Installer. For Alpine Linux, install `python3-dev` and `gcc`: `apk add python3-dev gcc`.
ImportError: cannot import name 'hash_unicode' from 'murmurhash'
This error indicates that the `hash_unicode` function, or similar specific hashing functions, are not directly available or have been renamed in the version of `murmurhash` you have installed, often due to an outdated or conflicting installation, especially when `murmurhash` is a dependency of another library like spaCy.
fix
Upgrade `murmurhash` to its latest version: `pip install --upgrade murmurhash`. If issues persist, consider reinstalling in a fresh virtual environment: `python -m venv .venv && source .venv/bin/activate && pip install murmurhash`.
AttributeError: module 'murmurhash' has no attribute 'hash'
This error occurs when you try to call a method named `hash` directly on the `murmurhash` module, but such a top-level function does not exist, or its name has changed in the installed version.
fix
The `murmurhash` library provides specific hashing functions like `murmurhash.murmur3_32()`, `murmurhash.murmur3_128()`, etc. Refer to the library's documentation or use `dir(murmurhash)` to find the correct function names. For example, use `murmurhash.murmur3_32('your string'.encode('utf-8'))`.
TypeError: a bytes-like object is required, not 'int'
The `murmurhash` functions expect binary data (bytes) as input, but you are providing an integer or a string that has not been explicitly encoded into bytes.
fix
Encode your input string to bytes before passing it to the hash function. For integers, convert them to their byte representation. Example: `murmurhash.murmur3_32('your string'.encode('utf-8'))` or `murmurhash.murmur3_32(b'your bytes')`.
Upgrade
Version history
1.0.15latest on PyPI · released Nov 14, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
murmurhash — pip install murmurhash · libregistry