Skip to main content

Implementation of the Jump Consistent Hash algorithm

Project description

Jump Consistent Hash

Build Status

Python and C implementation of the jump consistent hash algorithm by John Lamping and Eric Veach[1]. Tested on Python 3.6+.


To install Jump Consistent Hash, simply run this simple command in your terminal of choice:

$ pip install jump-consistent-hash

The C implementation is optional but is about 10x faster than the pure Python implementation in CPython.


>>> import jump
>>> jump.hash(256, 1024)

If you want to use a str as a key instead of an int, you can pass it through a hash function to compute a real key. Here’s a couple of examples using Python 3:

>>> import hashlib
>>> int(hashlib.md5(b"").hexdigest(), 16)

>>> int(hashlib.sha1(b"").hexdigest(), 16)

>>> import binascii
>>> binascii.crc32(b"") & 0xffffffff

>>> abs(hash(""))

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jump-consistent-hash-3.2.0.tar.gz (7.7 kB view hashes)

Uploaded source

Built Distributions

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page