Implementation of the Jump Consistent Hash algorithm
Project description
Jump Consistent Hash
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+.
Install
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 if it fails which is about 10x slower on 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
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for jump_consistent_hash-3.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1346b4459cf59ebe6b01fd4bec2a0da1f571d037811bce1d733c62acac26572f |
|
MD5 | 7b89f3c95075e8c31078b426db14d5ee |
|
BLAKE2b-256 | 37a353852b84851d34a1c2f218473170de32cd127372285aeaf20f7403da4228 |
Hashes for jump_consistent_hash-3.0.0-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f1db713c61a0db27f6ed57590c2ed0025d71e12654bfd37fef52e4bbdec62bf |
|
MD5 | 1f20f6ff37e691c02216a0151c5e7749 |
|
BLAKE2b-256 | 5dae5a75d99d5ce5e13ace3d6f1d278d44544949a0493b95d889af07739dcd98 |
Hashes for jump_consistent_hash-3.0.0-cp35-cp35m-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe28eac95021e0e7c430810ec09ccb4b51223e9bde9708e3aedd67578fb097b6 |
|
MD5 | e48d1c8dbd13d1e80f2cdae454f6dee6 |
|
BLAKE2b-256 | 7fc45ab60e1331a317d06275d8a1588dc53245c4335aca6857451a3a1df1e775 |
Hashes for jump_consistent_hash-3.0.0-cp34-cp34m-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4b205af76bed6853476652b974d568c2d1062939bbcae7c85776cf70f966310 |
|
MD5 | 86b8dd0481b4c1bdecd21336a2e3587f |
|
BLAKE2b-256 | 82485ba02eca7e9a4db063fb06e93cc33576a82f29207533fd8e7fe5c6fdec6a |
Hashes for jump_consistent_hash-3.0.0-cp27-cp27m-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7aba91e7895c8e57bd7c824825b4fbc27545ccbad94f885a71b3ad0b6ed0280 |
|
MD5 | 75080e4823bc5b02caa6a232c2fdaceb |
|
BLAKE2b-256 | 137d97da393bdbf6b1b876292e112a5faf01f6177bf37b75e290abd44b15e46d |