Registry / serialization / mmhash3

mmhash3

JSON →
library3.0.1pypypi✓ verified 22d ago

mmhash3 is a Python wrapper for MurmurHash (MurmurHash3), a collection of fast and robust non-cryptographic hash functions. This specific library (version 3.0.1, last updated Oct 2022) is a fork of the original 'mmh3' library, which was considered unmaintained at the time of its creation. For a more actively developed and current version of a MurmurHash3 Python wrapper, users often look to the 'mmh3' package (pypi.org/project/mmh3).

pip install mmhash3
INSTALL
IMPORT
SIG · MMHASH3
M
mmhash3
serializationpythonv3.0.1
Install
1.7s avg
Import
Disk
19MB
Pass rate
3/ 10
Env Coverage3 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.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
glibc
py 3.10
✕ build_error
✓ 1.7s
py 3.11
✕ build_error
✓ 1.5s
py 3.12
✕ build_error
✕ build_error
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 1.9s
19MB installed
● package 19MB
Code
Verified usage

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

hash
import mmh3 mmh3.hash('your_string')
import mmhash3
Despite the package name 'mmhash3', the main module to import is 'mmh3', consistent with its origins as a fork of the 'mmh3' library. Attempting to import 'mmhash3' directly will result in an ImportError.

Demonstrates basic hashing of strings using the default 32-bit algorithm, with and without a seed, and obtaining a 128-bit hash.

import mmh3 # Hash a string to a 32-bit signed integer hash_value_32_bit = mmh3.hash("hello world") print(f"32-bit hash: {hash_value_32_bit}") # Hash with a seed hash_value_seeded = mmh3.hash("hello world", 42) print(f"32-bit hash with seed 42: {hash_value_seeded}") # Get a 32-bit unsigned integer hash hash_value_unsigned = mmh3.hash("hello world", signed=False) print(f"32-bit unsigned hash: {hash_value_unsigned}") # Get a 128-bit hash as a single unsigned integer hash_value_128_bit = mmh3.hash128("hello world", 0) print(f"128-bit hash: {hash_value_128_bit}")
Debug
Known issues
gotchaThe library is installed via `pip install mmhash3`, but the Python module to import is `mmh3`. Importing `mmhash3` will fail.
fix
Always use `import mmh3` in your Python code.
affects: All versions of mmhash3
breakingResults of 32-bit `mmh3.hash()` changed in version 2.1 (prior to 3.0.1). If your application relies on specific hash values from very old `mmh3` versions (pre-2.1), the results from `mmhash3` (v3.0.1) will differ.
fix
Ensure your tests or dependent systems are updated to expect the hash values generated by current versions of MurmurHash3, or explicitly use older library versions if exact historical compatibility is critical and understood.
affects: 2.1 and later (including 3.0.1)
gotchaBy default, `mmh3.hash()` and `mmh3.hash64()` return signed integers, while `mmh3.hash128()` returns an unsigned integer. This can lead to different results compared to other MurmurHash3 implementations that might default to unsigned values. The `mmh3.hash64()` function also returns two 64-bit values as a tuple.
fix
Use the `signed=False` keyword argument for `mmh3.hash()` or `mmh3.hash64()` to obtain unsigned values if needed for compatibility with other systems or libraries. Be aware that `hash64` always returns two values.
affects: All versions (including 3.0.1)
gotchaThe behavior of seed values changed around version 2.4 (prior to 3.0.1), shifting from signed to unsigned 32-bit integers. While existing 32-bit signed seeds *should* yield the same results, using non-32-bit or intentionally negative seeds without careful consideration may lead to unexpected results or compatibility issues.
fix
Ensure seed values are 32-bit integers. For compatibility with older systems using negative 32-bit seeds, ensure the implicit conversion behavior is understood.
affects: 2.4 and later (including 3.0.1)
deprecatedThis `mmhash3` package (version 3.0.1) is a fork of an older, unmaintained `mmh3` library. For active development, newer Python versions support, and potential performance improvements, consider using the actively maintained `mmh3` package (github.com/hajimes/mmh3, pypi.org/project/mmh3) which is currently at version 5.x.x.
fix
Evaluate migrating to the actively maintained `mmh3` library (pip install mmh3) for ongoing support and features. Be aware of potential breaking changes if migrating, especially regarding endianness (mmh3 v4.0.0 made it endian-neutral) and seed handling.
affects: All versions of mmhash3 (PyPI slug)
Errors
Common errors & fixes
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/
The mmhash3 library contains C extensions that need to be compiled during installation if a pre-built wheel is not available for your specific Python version and operating system. This error indicates that the necessary C++ compiler tools are missing on a Windows system.
fix
Install the 'Microsoft C++ Build Tools' from the provided link or by selecting 'Desktop development with C++' in the Visual Studio Installer. For Linux, install `build-essential` (e.g., `sudo apt-get install build-essential`), and for macOS, install Xcode Command Line Tools (`xcode-select --install`).
ModuleNotFoundError: No module named 'mmh3'
This error typically occurs when the `mmhash3` package (which is imported as `mmh3`) was not installed successfully, or it was installed in a different Python environment than the one currently being used.
fix
Ensure you are in the correct Python environment. Try reinstalling the package using `pip install mmhash3`. If using a virtual environment, ensure it's activated. After successful installation, the module can be imported with `import mmh3`.
Getting different results from other MurmurHash3-based libraries
MurmurHash3 implementations can produce different results due to variations in handling signed/unsigned integer outputs, different default seed values, differences in 32-bit vs. 64-bit architecture optimization, or how string inputs are encoded.
fix
Ensure consistency across implementations by explicitly specifying parameters such as `signed=False` (to get unsigned results), `seed` (use the same seed value), and the `x64arch` parameter for 64-bit optimization when available (e.g., `mmh3.hash64('foo', seed=0, x64arch=True, signed=False)`). Also, ensure input strings are encoded consistently (e.g., `str.encode('utf-8')`).
Upgrade
Version history
3.0.1latest on PyPI · released Oct 29, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
4
Amazon
1
Resources
mmhash3 — pip install mmhash3 · libregistry