Registry / serialization / murmurhash2

murmurhash2

JSON →
library0.2.10pypypi✓ verified 84d ago

Murmurhash2 is a Python library providing fast, non-cryptographic hash functions, specifically bindings for the MurmurHash2 and MurmurHash3 algorithms. It is designed for high performance in applications such as hash tables, caching, and data distribution, rather than for security-sensitive use cases. The current version, 0.2.10, was last released in February 2022 and supports Python 3.6+ environments. The project appears to be in a maintenance status with infrequent updates.

pip install murmurhash2
INSTALL
IMPORT
SIG · MURMURHASH2
M
murmurhash2
serializationpythonv0.2.10
Install
1.6s avg
Import
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.10 · 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.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.2MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 22MB
20MB installed
● package 20MB
Code
Verified usage

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

murmurhash2
from murmurhash2 import murmurhash2
Imports the MurmurHash2 function.
murmurhash3
from murmurhash2 import murmurhash3
Imports the MurmurHash3 function, also provided by this library.

Demonstrates how to import and use both `murmurhash2` and `murmurhash3` functions. Input data must be provided as bytes.

from murmurhash2 import murmurhash2, murmurhash3 SEED = 3242157231 # A common seed value, can be any integer data_to_hash = b'Hello, MurmurHash!' # Input must be bytes hash_value_2 = murmurhash2(data_to_hash, SEED) hash_value_3 = murmurhash3(data_to_hash, SEED) print(f"MurmurHash2 of '{data_to_hash.decode()}' with seed {SEED}: {hash_value_2}") print(f"MurmurHash3 of '{data_to_hash.decode()}' with seed {SEED}: {hash_value_3}")
Debug
Known issues
breakingMurmurHash2 and MurmurHash3 are non-cryptographic hash functions. They are explicitly vulnerable to collision attacks (HashDoS) and must NOT be used for security-sensitive applications such as password hashing, digital signatures, or any context where an attacker can control input data.
fix
For security-sensitive applications, use cryptographic hash functions like `hashlib.sha256`.
affects: All versions
gotchaThe hash functions expect byte input. Passing a standard Python string (`str`) directly will result in a `TypeError` or unexpected behavior if the library attempts implicit conversion, which may not be platform-consistent.
fix
Always encode string inputs to bytes explicitly, e.g., `my_string.encode('utf-8')`.
affects: All versions
gotchaDue to its low-level C implementation, MurmurHash2 can be sensitive to endianness and data alignment across different platforms or when byte ordering is not strictly controlled, potentially leading to inconsistent hash values for the same logical input if the byte representation varies.
fix
Ensure consistent byte representation of input data, especially when hashing data structures or integers that might have different endianness on different systems. Test cross-platform consistency if required.
affects: All versions
deprecatedMurmurHash2 is an older algorithm. MurmurHash3, which is also provided by this library, is the more current version and often recommended over MurmurHash2 for improved distribution and performance characteristics.
fix
Consider using `murmurhash3` instead of `murmurhash2` for new implementations unless specific compatibility with MurmurHash2 is required.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'murmurhash2'
The `murmurhash2` package is not installed in the current Python environment or is not accessible via the Python path.
fix
Ensure the library is installed using pip: `pip install murmurhash2`
from murmurhash import murmurhash2
This is a common incorrect import pattern where users confuse the `murmurhash2` library with another, similarly named `murmurhash` library, or try to import a module that doesn't exist within the `murmurhash` package.
fix
To import functions from the `murmurhash2` library, use: `from murmurhash2 import murmurhash2, murmurhash3`
AttributeError: module 'murmurhash2' has no attribute 'murmurhash2'
This occurs when a user imports the `murmurhash2` module directly using `import murmurhash2` and then attempts to call `murmurhash2()` instead of accessing the function through the module namespace as `murmurhash2.murmurhash2()`.
fix
Either import the specific functions: `from murmurhash2 import murmurhash2, murmurhash3` or call the function using the module prefix: `import murmurhash2; murmurhash2.murmurhash2(b'key', 0)`
TypeError: a bytes-like object is required, not 'str'
The `murmurhash2` and `murmurhash3` functions in the `murmurhash2` library expect the input 'key' to be a bytes-like object, not a Python string.
fix
Encode your string to bytes before passing it to the hash function, e.g., `murmurhash2(b'your_string_here', SEED)` or `murmurhash2('your_string_here'.encode('utf-8'), SEED)`
Upgrade
Version history
0.2.10latest on PyPI · released Feb 12, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
murmurhash2 — pip install murmurhash2 · libregistry