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 murmurhashVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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.
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`.
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`.
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'))`.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')`.No dependency data recorded yet.