Skip to main content

Implementation of the Jump Consistent Hash algorithm

Project description

Jump Consistent Hash

Build Status

Python implementation of the jump consistent hash algorithm by John Lamping and Eric Veach[1]. Tested on Python 2.6, 2.7 and 3.4+.


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

$ pip install jump-consistent-hash

Unless running PyPy the installation will try to compile the C++ reference implementation (unless an appropriate wheel is available). If it fails it will fallback to the pure Python implementation which is about 10x slower on 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.

Filename, size & hash SHA256 hash help File type Python version Upload date
jump_consistent_hash-3.0.2-cp27-cp27m-macosx_10_13_x86_64.whl (5.1 kB) Copy SHA256 hash SHA256 Wheel cp27
jump_consistent_hash-3.0.2-cp36-cp36m-macosx_10_13_x86_64.whl (5.2 kB) Copy SHA256 hash SHA256 Wheel cp36
jump_consistent_hash-3.0.2.tar.gz (4.8 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page