mmh3 5.2.0


pip install mmh3

  Latest version

Released: Jul 29, 2025


Meta
Author: Hajime Senuma
Requires Python: >=3.9

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers

License
  • OSI Approved :: MIT License

Programming Language
  • Python :: 3
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: Free Threading :: 2 - Beta

Topic
  • Software Development :: Libraries
  • Utilities

mmh3

Documentation Status GitHub Super-Linter Build PyPi Version Python Versions License: MIT Total Downloads Recent Downloads DOI

mmh3 is a Python extension for MurmurHash (MurmurHash3), a set of fast and robust non-cryptographic hash functions invented by Austin Appleby.

By combining mmh3 with probabilistic techniques like Bloom filter, MinHash, and feature hashing, you can develop high-performance systems in fields such as data mining, machine learning, and natural language processing.

Another popular use of mmh3 is to calculate favicon hashes, which are utilized by Shodan, the world's first IoT search engine.

This page provides a quick start guide. For more comprehensive information, please refer to the documentation.

Installation

pip install mmh3

Usage

Basic usage

>>> import mmh3
>>> mmh3.hash(b"foo") # returns a 32-bit signed int
-156908512
>>> mmh3.hash("foo") # accepts str (UTF-8 encoded)
-156908512
>>> mmh3.hash(b"foo", 42) # uses 42 as the seed
-1322301282
>>> mmh3.hash(b"foo", 0, False) # returns a 32-bit unsigned int
4138058784

mmh3.mmh3_x64_128_digest(), introduced in version 5.0.0, efficienlty hashes buffer objects that implement the buffer protocol (PEP 688) without internal memory copying. The function returns a bytes object of 16 bytes (128 bits). It is particularly suited for hashing large memory views, such as bytearray, memoryview, and numpy.ndarray, and performs faster than the 32-bit variants like hash() on 64-bit machines.

>>> mmh3.mmh3_x64_128_digest(numpy.random.rand(100))
b'\x8c\xee\xc6z\xa9\xfeR\xe8o\x9a\x9b\x17u\xbe\xdc\xee'

Various alternatives are available, offering different return types (e.g., signed integers, tuples of unsigned integers) and optimized for different architectures. For a comprehensive list of functions, refer to the API Reference.

hashlib-style hashers

mmh3 implements hasher objects with interfaces similar to those in hashlib from the standard library, although they are still experimental. See Hasher Classes in the API Reference for more information.

Changelog

See Changelog (latest version) for the complete changelog.

5.2.0 - 2025-07-29

Added

  • Add support for Python 3.14, including 3.14t (no-GIL) wheels. However, thread safety for the no-GIL variant is not fully tested yet. Please report any issues you encounter (#134, #136).
  • Add support for Android (Python 3.13 only) and iOS (Python 3.13 and 3.14) wheels, enabled by the major version update of cibuildwheel (#135).

5.1.0 - 2025-01-25

Added

Removed

  • Drop support for Python 3.8, as it has reached the end of life on 2024-10-07 (#117).

5.0.1 - 2024-09-22

Fixed

  • Fix the issue that the package cannot be built from the source distribution (#90).

License

MIT, unless otherwise noted within a file.

Frequently Asked Questions

Different results from other MurmurHash3-based libraries

By default, mmh3 returns signed values for the 32-bit and 64-bit versions and unsigned values for hash128 due to historical reasons. To get the desired result, use the signed keyword argument.

Starting from version 4.0.0, mmh3 is endian-neutral, meaning that its hash functions return the same values on big-endian platforms as they do on little-endian ones. In contrast, the original C++ library by Appleby is endian-sensitive. If you need results that comply with the original library on big-endian systems, please use version 3.*.

For compatibility with Google Guava (Java), see https://stackoverflow.com/questions/29932956/murmur3-hash-different-result-between-python-and-java-implementation.

For compatibility with murmur3 (Go), see https://github.com/hajimes/mmh3/issues/46.

Handling errors with negative seeds

From the version 5.0.0, mmh3 functions accept only unsigned 32-bit integer seeds to enable faster type-checking and conversion. However, this change may cause issues if you need to calculate hash values using negative seeds within the range of signed 32-bit integers. For instance, Telegram-iOS uses -137723950 as a hard-coded seed (bitwise equivalent to 4157243346). To handle such cases, you can convert a signed 32-bit integer to its unsigned equivalent by applying a bitwise AND operation with 0xffffffff. Here's an example:

>>> mmh3.hash(b"quux", 4294967295)
258499980
>>> d = -1
>>> mmh3.hash(b"quux", d & 0xffffffff)
258499980

Alternatively, if the seed is hard-coded (as in the Telegram-iOS case), you can precompute the unsigned value for simplicity.

Contributing Guidelines

See Contributing.

Authors

MurmurHash3 was originally developed by Austin Appleby and distributed under public domain https://github.com/aappleby/smhasher.

Ported and modified for Python by Hajime Senuma.

External Tutorials

High-performance computing

The following textbooks and tutorials are great resources for learning how to use mmh3 (and other hash algorithms in general) for high-performance computing.

Internet of things

Shodan, the world's first IoT search engine, uses MurmurHash3 hash values for favicons (icons associated with web pages). ZoomEye follows Shodan's convention. Calculating these values with mmh3 is useful for OSINT and cybersecurity activities.

How to Cite This Library

If you use this library in your research, it would be appreciated if you could cite the following paper published in the Journal of Open Source Software:

Hajime Senuma. 2025. mmh3: A Python extension for MurmurHash3. Journal of Open Source Software, 10(105):6124.

In BibTeX format:

@article{senumaMmh3PythonExtension2025,
  title = {{mmh3}: A {Python} extension for {MurmurHash3}},
  author = {Senuma, Hajime},
  year = {2025},
  month = jan,
  journal = {Journal of Open Source Software},
  volume = {10},
  number = {105},
  pages = {6124},
  issn = {2475-9066},
  doi = {10.21105/joss.06124},
  copyright = {http://creativecommons.org/licenses/by/4.0/}
}

Related Libraries

Wheel compatibility matrix

Platform CPython 3.9 CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython 3.14 CPython (additional flags: t) 3.14
android_21_arm64_v8a
android_21_x86_64
ios_13_0_arm64_iphoneos
ios_13_0_arm64_iphonesimulator
ios_13_0_x86_64_iphonesimulator
macosx_10_13_universal2
macosx_10_13_x86_64
macosx_10_9_universal2
macosx_10_9_x86_64
macosx_11_0_arm64
manylinux1_i686
manylinux1_x86_64
manylinux2014_aarch64
manylinux2014_ppc64le
manylinux2014_s390x
manylinux_2_17_aarch64
manylinux_2_17_ppc64le
manylinux_2_17_s390x
manylinux_2_28_aarch64
manylinux_2_28_i686
manylinux_2_28_ppc64le
manylinux_2_28_s390x
manylinux_2_28_x86_64
manylinux_2_5_i686
manylinux_2_5_x86_64
musllinux_1_2_aarch64
musllinux_1_2_i686
musllinux_1_2_ppc64le
musllinux_1_2_s390x
musllinux_1_2_x86_64
win32
win_amd64
win_arm64

Files in release

mmh3-5.2.0-cp310-cp310-macosx_10_9_universal2.whl (54.8KiB)
mmh3-5.2.0-cp310-cp310-macosx_10_9_x86_64.whl (39.7KiB)
mmh3-5.2.0-cp310-cp310-macosx_11_0_arm64.whl (39.1KiB)
mmh3-5.2.0-cp310-cp310-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (93.1KiB)
mmh3-5.2.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (98.8KiB)
mmh3-5.2.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (101.6KiB)
mmh3-5.2.0-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (108.3KiB)
mmh3-5.2.0-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (115.6KiB)
mmh3-5.2.0-cp310-cp310-musllinux_1_2_aarch64.whl (99.3KiB)
mmh3-5.2.0-cp310-cp310-musllinux_1_2_i686.whl (94.4KiB)
mmh3-5.2.0-cp310-cp310-musllinux_1_2_ppc64le.whl (107.7KiB)
mmh3-5.2.0-cp310-cp310-musllinux_1_2_s390x.whl (109.3KiB)
mmh3-5.2.0-cp310-cp310-musllinux_1_2_x86_64.whl (97.8KiB)
mmh3-5.2.0-cp310-cp310-win32.whl (39.8KiB)
mmh3-5.2.0-cp310-cp310-win_amd64.whl (40.6KiB)
mmh3-5.2.0-cp310-cp310-win_arm64.whl (38.4KiB)
mmh3-5.2.0-cp311-cp311-macosx_10_9_universal2.whl (54.8KiB)
mmh3-5.2.0-cp311-cp311-macosx_10_9_x86_64.whl (39.7KiB)
mmh3-5.2.0-cp311-cp311-macosx_11_0_arm64.whl (39.1KiB)
mmh3-5.2.0-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (95.0KiB)
mmh3-5.2.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (100.7KiB)
mmh3-5.2.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (103.6KiB)
mmh3-5.2.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (110.3KiB)
mmh3-5.2.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (117.8KiB)
mmh3-5.2.0-cp311-cp311-musllinux_1_2_aarch64.whl (96.8KiB)
mmh3-5.2.0-cp311-cp311-musllinux_1_2_i686.whl (96.2KiB)
mmh3-5.2.0-cp311-cp311-musllinux_1_2_ppc64le.whl (103.8KiB)
mmh3-5.2.0-cp311-cp311-musllinux_1_2_s390x.whl (107.2KiB)
mmh3-5.2.0-cp311-cp311-musllinux_1_2_x86_64.whl (95.0KiB)
mmh3-5.2.0-cp311-cp311-win32.whl (39.8KiB)
mmh3-5.2.0-cp311-cp311-win_amd64.whl (40.6KiB)
mmh3-5.2.0-cp311-cp311-win_arm64.whl (38.4KiB)
mmh3-5.2.0-cp312-cp312-macosx_10_13_universal2.whl (54.8KiB)
mmh3-5.2.0-cp312-cp312-macosx_10_13_x86_64.whl (39.7KiB)
mmh3-5.2.0-cp312-cp312-macosx_11_0_arm64.whl (39.1KiB)
mmh3-5.2.0-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (95.1KiB)
mmh3-5.2.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (100.9KiB)
mmh3-5.2.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (103.7KiB)
mmh3-5.2.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (110.4KiB)
mmh3-5.2.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (118.0KiB)
mmh3-5.2.0-cp312-cp312-musllinux_1_2_aarch64.whl (96.8KiB)
mmh3-5.2.0-cp312-cp312-musllinux_1_2_i686.whl (96.4KiB)
mmh3-5.2.0-cp312-cp312-musllinux_1_2_ppc64le.whl (104.0KiB)
mmh3-5.2.0-cp312-cp312-musllinux_1_2_s390x.whl (107.5KiB)
mmh3-5.2.0-cp312-cp312-musllinux_1_2_x86_64.whl (95.3KiB)
mmh3-5.2.0-cp312-cp312-win32.whl (39.8KiB)
mmh3-5.2.0-cp312-cp312-win_amd64.whl (40.6KiB)
mmh3-5.2.0-cp312-cp312-win_arm64.whl (38.4KiB)
mmh3-5.2.0-cp313-cp313-android_21_arm64_v8a.whl (39.9KiB)
mmh3-5.2.0-cp313-cp313-android_21_x86_64.whl (41.0KiB)
mmh3-5.2.0-cp313-cp313-ios_13_0_arm64_iphoneos.whl (38.3KiB)
mmh3-5.2.0-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl (38.9KiB)
mmh3-5.2.0-cp313-cp313-ios_13_0_x86_64_iphonesimulator.whl (39.7KiB)
mmh3-5.2.0-cp313-cp313-macosx_10_13_universal2.whl (54.8KiB)
mmh3-5.2.0-cp313-cp313-macosx_10_13_x86_64.whl (39.7KiB)
mmh3-5.2.0-cp313-cp313-macosx_11_0_arm64.whl (39.1KiB)
mmh3-5.2.0-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (95.1KiB)
mmh3-5.2.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (100.9KiB)
mmh3-5.2.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (103.8KiB)
mmh3-5.2.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (110.4KiB)
mmh3-5.2.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (118.0KiB)
mmh3-5.2.0-cp313-cp313-musllinux_1_2_aarch64.whl (96.8KiB)
mmh3-5.2.0-cp313-cp313-musllinux_1_2_i686.whl (96.4KiB)
mmh3-5.2.0-cp313-cp313-musllinux_1_2_ppc64le.whl (104.0KiB)
mmh3-5.2.0-cp313-cp313-musllinux_1_2_s390x.whl (107.5KiB)
mmh3-5.2.0-cp313-cp313-musllinux_1_2_x86_64.whl (95.3KiB)
mmh3-5.2.0-cp313-cp313-win32.whl (39.8KiB)
mmh3-5.2.0-cp313-cp313-win_amd64.whl (40.6KiB)
mmh3-5.2.0-cp313-cp313-win_arm64.whl (38.4KiB)
mmh3-5.2.0-cp314-cp314-ios_13_0_arm64_iphoneos.whl (38.3KiB)
mmh3-5.2.0-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl (38.9KiB)
mmh3-5.2.0-cp314-cp314-ios_13_0_x86_64_iphonesimulator.whl (39.7KiB)
mmh3-5.2.0-cp314-cp314-macosx_10_13_universal2.whl (54.8KiB)
mmh3-5.2.0-cp314-cp314-macosx_10_13_x86_64.whl (39.7KiB)
mmh3-5.2.0-cp314-cp314-macosx_11_0_arm64.whl (39.1KiB)
mmh3-5.2.0-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (95.1KiB)
mmh3-5.2.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (100.9KiB)
mmh3-5.2.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (103.8KiB)
mmh3-5.2.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (110.5KiB)
mmh3-5.2.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (117.9KiB)
mmh3-5.2.0-cp314-cp314-musllinux_1_2_aarch64.whl (96.9KiB)
mmh3-5.2.0-cp314-cp314-musllinux_1_2_i686.whl (96.4KiB)
mmh3-5.2.0-cp314-cp314-musllinux_1_2_ppc64le.whl (104.0KiB)
mmh3-5.2.0-cp314-cp314-musllinux_1_2_s390x.whl (107.5KiB)
mmh3-5.2.0-cp314-cp314-musllinux_1_2_x86_64.whl (95.3KiB)
mmh3-5.2.0-cp314-cp314-win32.whl (40.5KiB)
mmh3-5.2.0-cp314-cp314-win_amd64.whl (41.1KiB)
mmh3-5.2.0-cp314-cp314-win_arm64.whl (38.9KiB)
mmh3-5.2.0-cp314-cp314t-macosx_10_13_universal2.whl (56.3KiB)
mmh3-5.2.0-cp314-cp314t-macosx_10_13_x86_64.whl (40.5KiB)
mmh3-5.2.0-cp314-cp314t-macosx_11_0_arm64.whl (39.9KiB)
mmh3-5.2.0-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (107.1KiB)
mmh3-5.2.0-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (114.7KiB)
mmh3-5.2.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (117.6KiB)
mmh3-5.2.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (123.0KiB)
mmh3-5.2.0-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (132.2KiB)
mmh3-5.2.0-cp314-cp314t-musllinux_1_2_aarch64.whl (107.5KiB)
mmh3-5.2.0-cp314-cp314t-musllinux_1_2_i686.whl (108.6KiB)
mmh3-5.2.0-cp314-cp314t-musllinux_1_2_ppc64le.whl (114.2KiB)
mmh3-5.2.0-cp314-cp314t-musllinux_1_2_s390x.whl (120.3KiB)
mmh3-5.2.0-cp314-cp314t-musllinux_1_2_x86_64.whl (107.6KiB)
mmh3-5.2.0-cp314-cp314t-win32.whl (41.0KiB)
mmh3-5.2.0-cp314-cp314t-win_amd64.whl (42.1KiB)
mmh3-5.2.0-cp314-cp314t-win_arm64.whl (39.5KiB)
mmh3-5.2.0-cp39-cp39-macosx_10_9_universal2.whl (54.8KiB)
mmh3-5.2.0-cp39-cp39-macosx_10_9_x86_64.whl (39.7KiB)
mmh3-5.2.0-cp39-cp39-macosx_11_0_arm64.whl (39.1KiB)
mmh3-5.2.0-cp39-cp39-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl (92.9KiB)
mmh3-5.2.0-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (98.6KiB)
mmh3-5.2.0-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (101.3KiB)
mmh3-5.2.0-cp39-cp39-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl (108.1KiB)
mmh3-5.2.0-cp39-cp39-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl (115.3KiB)
mmh3-5.2.0-cp39-cp39-musllinux_1_2_aarch64.whl (99.1KiB)
mmh3-5.2.0-cp39-cp39-musllinux_1_2_i686.whl (94.2KiB)
mmh3-5.2.0-cp39-cp39-musllinux_1_2_ppc64le.whl (107.5KiB)
mmh3-5.2.0-cp39-cp39-musllinux_1_2_s390x.whl (109.1KiB)
mmh3-5.2.0-cp39-cp39-musllinux_1_2_x86_64.whl (97.5KiB)
mmh3-5.2.0-cp39-cp39-win32.whl (39.8KiB)
mmh3-5.2.0-cp39-cp39-win_amd64.whl (40.6KiB)
mmh3-5.2.0-cp39-cp39-win_arm64.whl (38.4KiB)
mmh3-5.2.0.tar.gz (32.8KiB)
Extras:
Dependencies: