{"id":658,"library":"mmh3","title":"mmh3 (MurmurHash3)","description":"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.","status":"active","version":"5.2.1","language":"python","source_language":"en","source_url":"https://github.com/hajimes/mmh3","tags":["hashing","murmurhash","utility","fast","hash-function","non-cryptographic"],"install":[{"cmd":"pip install mmh3","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.10 or newer.","package":"python","optional":false}],"imports":[{"note":"All primary hash functions and hasher classes are available directly under the `mmh3` module.","symbol":"mmh3","correct":"import mmh3"}],"quickstart":{"code":"import mmh3\n\n# Basic 32-bit hash, returns a signed integer\nhash_value = mmh3.hash(\"foo\")\nprint(f\"32-bit signed hash of 'foo': {hash_value}\")\n\n# 32-bit hash with a seed\nhash_with_seed = mmh3.hash(\"foo\", seed=42)\nprint(f\"32-bit signed hash of 'foo' with seed 42: {hash_with_seed}\")\n\n# 32-bit unsigned hash\nunsigned_hash = mmh3.hash(\"foo\", signed=False)\nprint(f\"32-bit unsigned hash of 'foo': {unsigned_hash}\")\n\n# 128-bit hash as a string of bytes\nhash_as_bytes = mmh3.hash_bytes(\"foo\")\nprint(f\"128-bit hash of 'foo' as bytes: {hash_as_bytes}\")\n\n# 64-bit hash (returns a tuple of two 64-bit signed integers)\nhash64_result = mmh3.hash64(\"foo\")\nprint(f\"64-bit hash of 'foo': {hash64_result}\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade to Python 3.10 or newer, or downgrade `mmh3` to a version compatible with your Python environment.","message":"Support for Python 3.9 was dropped in version 5.2.1, and earlier versions dropped support for Python 3.7 (v4.0.0) and Python 3.6 (v3.1.0). Users on unsupported Python versions must either upgrade their Python environment or pin to an older `mmh3` version.","severity":"breaking","affected_versions":">=5.2.1, >=4.0.0, >=3.1.0"},{"fix":"If strict compatibility with original C++ MurmurHash3 on big-endian systems is required, use `mmh3` version 3.*. Otherwise, re-evaluate hash values for applications.","message":"Starting from version 4.0.0, mmh3 became endian-neutral, meaning its hash functions return the same values on big-endian platforms as on little-endian ones. This is a backward-incompatible change for users who relied on endian-sensitive behavior on big-endian systems.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"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.","message":"In version 5.0.0, the `seed` argument for hash functions became strictly validated to ensure it falls within the unsigned 32-bit integer range `[0, 0xFFFFFFFF]`. Providing a negative or out-of-range seed now raises a `ValueError`.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"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).","message":"The `hash_from_buffer()` function was deprecated in version 5.0.0. It is recommended to use the newer, more performant `mmh3_32_sintdigest()` or `mmh3_32_uintdigest()` functions as alternatives for hashing buffer objects.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"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.","message":"By default, `mmh3.hash()` and `mmh3.hash64()` return signed integer values, while `mmh3.hash128()` returns an unsigned integer. To obtain unsigned results for 32-bit or 64-bit hashes, you must explicitly pass `signed=False`. For 128-bit hashes, `signed=True` is needed for signed output.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Version 5.2.0 introduced experimental support for Python 3.14t (no-GIL) wheels. However, thread safety for this no-GIL variant is not yet fully tested. Use with caution in multi-threaded environments.","severity":"gotcha","affected_versions":">=5.2.0"},{"fix":"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.","message":"The `mmh3.hash64()` function returns a tuple of two 64-bit integers, unlike `mmh3.hash()` which returns a single 32-bit integer, because it uses the 128-bit MurmurHash3 algorithm internally and splits the result. This can be a point of confusion if a single 64-bit integer is expected.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T17:26:18.023Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install the package using pip: `pip install mmh3`","cause":"The mmh3 package is not installed in the Python environment being used or is not accessible in the current Python path.","error":"ModuleNotFoundError: No module named 'mmh3'"},{"fix":"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.","cause":"This error often occurs in specific environments like Bazel, or when there's a packaging issue that prevents the 'hash' function from being directly accessible via `mmh3.hash`, especially after version 4.0.0.","error":"AttributeError: module 'mmh3' has no attribute 'hash'"},{"fix":"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.","cause":"When installing mmh3 on Windows, a C++ compiler is needed to build the extension modules, and it is not found on the system.","error":"error: Microsoft Visual C++ 14.0 or greater is required."}],"ecosystem":"pypi","meta_description":null,"install_score":80,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"5.2.1","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"18.1M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"18.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0,"mem_mb":0,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"20.0M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"20.0M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":0,"mem_mb":0,"disk_size":"21M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.8M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.8M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":0,"mem_mb":0,"disk_size":"12M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.6M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"11.5M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.5,"import_time_s":0,"mem_mb":0,"disk_size":"12M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"17.6M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"17.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.1,"import_time_s":0,"mem_mb":0,"disk_size":"18M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0,"mem_mb":0,"disk_size":"18M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}