mmhash3 (MurmurHash3)

3.0.1 · maintenance · verified Mon Apr 13

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).

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →