Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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 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
Release History

Release History

This version
History Node

3.0.1

History Node

3.0.0

History Node

2.0.3

History Node

2.0.2

History Node

2.0.1

History Node

2.0.0

History Node

1.1.1

History Node

1.1.0

History Node

1.0.4

History Node

1.0.3

History Node

1.0.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
jump_consistent_hash-3.0.1-cp27-cp27m-macosx_10_13_x86_64.whl (6.8 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Aug 27, 2017
jump_consistent_hash-3.0.1-cp36-cp36m-macosx_10_13_x86_64.whl (6.9 kB) Copy SHA256 Checksum SHA256 cp36 Wheel Aug 27, 2017
jump_consistent_hash-3.0.1.tar.gz (4.9 kB) Copy SHA256 Checksum SHA256 Source Aug 27, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting