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!

Python bindings for MetroHash, a fast non-cryptographic hash algorithm

Project Description

A Python wrapper around MetroHash

Getting Started

To use this package in your program, simply enter

pip install metrohash

After that, you should be able to import the module and do things with it (see Example Usage below).

If you want to contribute to this package by developing, the included Makefile provides some useful commands to help you with that task:

git clone https://github.com/escherba/python-metrohash.git
cd python-metrohash
make env           # creates a Python virtualenv
make test          # builds and runs C++ and Python tests

Example Usage

This package provides Python interfaces to 64- and 128-bit implementations of MetroHash algorithm. For stateless hashing, it exports metrohash64 and metrohash128 functions. Both take a value to be hashed (either string or unicode) and an optional seed parameter:

>>> import metrohash
...
>>> metrohash.metrohash64("abc", seed=0)
17099979927131455419L
>>> metrohash.metrohash128("abc")
182995299641628952910564950850867298725L

For incremental hashing, use MetroHash64 and MetroHash128 classes. Incremental hashing is associative and guarantees that any combination of input slices will result in the same final hash value. This is useful for processing large inputs and stream data. Example with two slices:

>>> mh = metrohash.MetroHash64()
>>> mh.update("Nobody inspects")
>>> mh.update(" the spammish repetition")
>>> mh.intdigest()
7851180100622203313L

Note that the resulting hash value above is the same as in:

>>> mh = metrohash.MetroHash64()
>>> mh.update("Nobody inspects the spammish repetition")
>>> mh.intdigest()
7851180100622203313L

See Also

For other fast non-cryptographic hashing implementations available as Python extensions, see CityHash and xxh.

Authors

The original MetroHash algorithm was designed by J. Andrew Rogers. The Python bindings in this package were written by Eugene Scherba.

License

This software is licensed under the MIT License. See the included LICENSE file for more information.

Release History

Release History

This version
History Node

0.0.13

History Node

0.0.12

History Node

0.0.11

History Node

0.0.9

History Node

0.0.8

History Node

0.0.7

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

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
metrohash-0.0.13-cp27-none-macosx_10_10_x86_64.whl (22.5 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Oct 28, 2015
metrohash-0.0.13.tar.gz (33.9 kB) Copy SHA256 Checksum SHA256 Source Oct 28, 2015

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