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 2.7 and 3.4+.

Install

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.

Usage

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

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'127.0.0.1').hexdigest(), 16)
325870950296970981340734819828239218902

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

>>> import binascii
>>> binascii.crc32(b'127.0.0.1') & 0xffffffff
3619153832

>>> abs(hash('127.0.0.1'))
7536019783825143230

Project details


Download files

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

Files for jump-consistent-hash, version 3.1.1
Filename, size File type Python version Upload date Hashes
Filename, size jump_consistent_hash-3.1.1-cp27-cp27m-macosx_10_13_x86_64.whl (5.5 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp27-cp27m-manylinux1_i686.whl (11.9 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp27-cp27m-manylinux1_x86_64.whl (15.7 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp27-cp27m-manylinux2010_x86_64.whl (15.7 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp27-cp27mu-manylinux1_i686.whl (11.9 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp27-cp27mu-manylinux1_x86_64.whl (15.7 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp27-cp27mu-manylinux2010_x86_64.whl (15.7 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp27-cp27m-win_amd64.whl (7.1 kB) File type Wheel Python version cp27 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp35-cp35m-macosx_10_13_x86_64.whl (5.6 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp35-cp35m-manylinux1_i686.whl (12.0 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp35-cp35m-manylinux1_x86_64.whl (11.9 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp35-cp35m-manylinux2010_x86_64.whl (16.9 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp35-cp35m-win_amd64.whl (9.1 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp36-cp36m-macosx_10_13_x86_64.whl (5.6 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp36-cp36m-manylinux1_i686.whl (12.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp36-cp36m-manylinux1_x86_64.whl (17.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp36-cp36m-manylinux2010_x86_64.whl (17.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp36-cp36m-win_amd64.whl (9.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp37-cp37m-macosx_10_13_x86_64.whl (5.6 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp37-cp37m-manylinux1_i686.whl (12.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp37-cp37m-manylinux1_x86_64.whl (18.0 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp37-cp37m-manylinux2010_x86_64.whl (18.0 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp37-cp37m-win_amd64.whl (9.1 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp38-cp38-macosx_10_13_x86_64.whl (5.6 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp38-cp38-manylinux1_i686.whl (12.2 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp38-cp38-manylinux1_x86_64.whl (17.0 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp38-cp38-manylinux2010_x86_64.whl (17.0 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size jump_consistent_hash-3.1.1-cp38-cp38-win_amd64.whl (9.1 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size jump-consistent-hash-3.1.1.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page