Implementation of the Jump Consistent Hash algorithm
Project description
Python implementation of the jump consistent hash algorithm by John Lamping and Eric Veach[1]. Requires Python 2.6-2.7 or 3.2+.
Usage
>>> import jump
>>> jump.hash(256, 1024)
520
Or if you want to use the C++ extension:
>>> jump.fasthash(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
Close
Hashes for jump_consistent_hash-2.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72daed3602c030b0e3e18a5a90e5745580282945e9d401b4eb19810880a481db |
|
MD5 | bf0b1be48d187ff9ad2f221d4242357b |
|
BLAKE2b-256 | 29c0cc07e815ef9abfc76d7a31c20b8dc85171f46d94afc46c77bc75272d6561 |
Close
Hashes for jump_consistent_hash-2.0.2-cp35-cp35m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a315ec3488a3b7813c71438737f2f8db3641c9ebb417f94caff4919d24a6e656 |
|
MD5 | 0631d10367a9160b78dd63f9bd6ee88c |
|
BLAKE2b-256 | 6b3eee1755848fa3984b12526dbc45d88aaf62e18f28bfd090b915ce5f03234a |
Close
Hashes for jump_consistent_hash-2.0.2-cp27-none-macosx_10_11_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b24e952957ea99dc58dcfa055c78ada4f8677564b3115413aee350000e63f34 |
|
MD5 | a83337cd53aa0a7a3a3bb488a5122126 |
|
BLAKE2b-256 | 7d962523a32e9ac587c4ccb076afb3cf896b8773741877eea9b364b752fb8258 |