mmh3 is a Python extension for MurmurHash (MurmurHash3), a collection of fast and robust non-cryptographic hash functions invented by Austin Appleby. Currently at version 5.2.1, it is actively maintained with updates for new Python versions, performance enhancements, and extended platform support for applications in data mining, machine learning, and natural language processing.
pip install mmh3Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the most common `mmh3` hash functions: `hash()` for 32-bit results (signed or unsigned), `hash_bytes()` for 128-bit results as bytes, and `hash64()` for 64-bit results as a tuple of two integers. The `seed` and `signed` arguments are crucial for consistent results.
Upgrade to Python 3.10 or newer, or downgrade `mmh3` to a version compatible with your Python environment.
If strict compatibility with original C++ MurmurHash3 on big-endian systems is required, use `mmh3` version 3.*. Otherwise, re-evaluate hash values for applications.
Ensure all seed values passed to `mmh3` functions are non-negative and within the 32-bit unsigned integer range. Convert any negative seeds if they represent a valid unsigned equivalent.
Replace calls to `mmh3.hash_from_buffer()` with `mmh3.mmh3_32_sintdigest()` (for signed integer output) or `mmh3.mmh3_32_uintdigest()` (for unsigned integer output).
Always use the `signed` keyword argument (e.g., `mmh3.hash('data', signed=False)`) to explicitly control the output type (signed or unsigned) and ensure consistent results across different hash functions or desired interpretations.If thread safety is critical in a no-GIL environment, perform thorough testing or consider using standard GIL-enabled Python distributions until thread safety is fully verified for the no-GIL `mmh3` builds.
Be aware that `mmh3.hash64()` always returns a tuple. If a single 64-bit integer representation is needed, custom logic to combine or select from the tuple components will be required.
Install the package using pip: `pip install mmh3`
Ensure `mmh3` is correctly installed and its modules are properly resolved in your environment. For Bazel users, refer to specific Bazel integration solutions or ensure a compatible `mmh3` version is used that works with your build setup. If this is a recent upgrade, rolling back to an earlier version (e.g., `pip install mmh3==4.0.0`) might temporarily resolve it, then check for environment-specific resolutions.
Install the 'Microsoft C++ Build Tools' which provides the necessary compiler. These can be downloaded from Visual Studio's website or by selecting 'Desktop development with C++' in the Visual Studio installer. After installation, try `pip install mmh3` again.