Python bindings for CityHash and FarmHash
pip install cityhashCityHash/FarmHash
Python wrapper for FarmHash and CityHash, a family of fast non-cryptographic hash functions.
Getting Started
To install from PyPI:
pip install cityhash
To install in a Conda environment:
conda install -c conda-forge python-cityhash
The package exposes Python APIs for CityHash and FarmHash under cityhash and
farmhash namespaces, respectively. Each provides 32-, 64- and 128-bit
implementations.
Usage Examples
Stateless hashing
Usage example for FarmHash:
>>> from farmhash import FarmHash32, FarmHash64, FarmHash128
>>> FarmHash32("abc")
1961358185
>>> FarmHash64("abc")
2640714258260161385
>>> FarmHash128("abc")
76434233956484675513733017140465933893
Hardware-independent fingerprints
Fingerprints are seedless hashes that are guaranteed to be hardware- and platform-independent. This can be useful for networking applications that persist hashed values.
>>> from farmhash import Fingerprint128
>>> Fingerprint128("abc")
76434233956484675513733017140465933893
Incremental hashing
CityHash and FarmHash do not support incremental hashing and thus are not ideal for hashing of long character streams. If you require incremental hashing, consider another hashing library, such as or .