cityhash
Python bindings for CityHash and FarmHash
What it is and what it does
Cityhash is a Python binding to Google's CityHash and FarmHash algorithms—a family of fast, non-cryptographic hash functions designed for speed rather than cryptographic security. It exposes multiple bit-width variants (32, 64, 128) under separate namespaces and supports hardware-independent fingerprints that remain consistent across platforms, making them suitable for distributed systems that need to persist hashed values. The package can hash any object that implements Python's buffer protocol without copying data to memory.
The package is built from compiled C++ bindings and ships pre-built wheels for major platforms and Python versions, reducing installation friction. It explicitly does not support incremental hashing. On x86-64 systems, wheels include SSE4.2 optimizations that significantly accelerate certain hash variants, though the vanilla CityHash functions do not benefit from these instructions.
Use it for:
- Hash large NumPy arrays efficiently without copying data in machine learning or scientific computing pipelines.
- Generate hardware-independent fingerprints for distributed caching or load-balancing systems needing consistent hashes across machines.
- Fast non-cryptographic hashing in high-throughput applications where speed matters more than cryptographic strength.
- Implement consistent hashing for data partitioning in distributed databases or key-value stores.
- Hash fixed-size data structures in performance-critical sections where cryptographic guarantees are unnecessary.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python wrapper for Google's CityHash and FarmHash non-cryptographic hash functions, offering 32-, 64-, and 128-bit implementations with support for hardware-independent fingerprints and fast hashing of buffer-protocol objects like NumPy arrays.
Yes, if you need fast non-cryptographic hashing with buffer-protocol support and don't require incremental hashing. Pre-built wheels and broad platform coverage make installation straightforward. The aging maintenance status (309 days since release) is a minor concern but not a blocker—the package is stable with no known vulnerabilities. Skip it if you need cryptographic hashing or streaming/incremental hashing.
Install
cityhash on PyPI
pip
pip install cityhashuv
uv add cityhashpoetry
poetry add cityhashInstalling cityhash
Before you install
Medium install friction due to compiled C++ bindings; wheels are pre-built for common platforms (Windows, macOS, Linux x86_64 and ARM64) across Python 3.10–3.13, reducing compilation overhead. Repository shows aging maintenance (309 days since last release) but remains stable.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in both open-source and proprietary projects with minimal restrictions.
Quickstart
pip install cityhash
from cityhash import CityHash64
result = CityHash64("abc")
print(result)
Requires Python 3.6 or later; buffer-protocol objects like NumPy arrays must be contiguous.
Verify before relying
- Whether SSE4.2 support on x86-64 platforms is automatically detected and used at runtime.
- Performance characteristics compared to other non-cryptographic hash libraries in real-world workloads.
- Whether the aging maintenance status affects bug-fix responsiveness or security patching.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | aging — 309 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 406,355/month — #6,897 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cityhash-0.4.10-cp310-cp310-macosx_10_9_x86_64.whl; cityhash-0.4.10-cp310-cp310-macosx_11_0_arm64.whl; cityhash-0.4.10-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; cityhash-0.4.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; cityhash-0.4.10-cp310-cp310-win32.whl; cityhash-0.4.10-cp310-cp310-win_amd64.whl; cityhash-0.4.10-cp311-cp311-macosx_10_9_x86_64.whl; cityhash-0.4.10-cp311-cp311-macosx_11_0_arm64.whl; cityhash-0.4.10-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; cityhash-0.4.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; cityhash-0.4.10-cp311-cp311-win32.whl; cityhash-0.4.10-cp311-cp311-win_amd64.whl; cityhash-0.4.10-cp312-cp312-macosx_10_13_x86_64.whl; cityhash-0.4.10-cp312-cp312-macosx_11_0_arm64.whl; cityhash-0.4.10-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; cityhash-0.4.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; cityhash-0.4.10-cp312-cp312-win32.whl; cityhash-0.4.10-cp312-cp312-win_amd64.whl; cityhash-0.4.10-cp313-cp313-macosx_10_13_x86_64.whl; cityhash-0.4.10-cp313-cp313-macosx_11_0_arm64.whl
Keywords: google, hash, hashing, cityhash, farmhash, murmurhash, cython
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
clickhouse-cityhashProvides Python bindings to CityHash, a fast…
permissive · top 15,000 on PyPI
pyfarmhashProvides Python bindings to Google's FarmHash,…
permissive · top 15,000 on PyPI
spookyhashProvides fast 32-, 64-, and 128-bit hashing via…
permissive · top 15,000 on PyPI
mmhash3mmhash3 is a Python wrapper for MurmurHash3,…
permissive · top 15,000 on PyPI
polars-hashPolars-hash adds cryptographic and…
unclear · top 15,000 on PyPI
mmh3mmh3 is a Python binding to MurmurHash3, a fast…
permissive · top 1,000 on PyPI
xxhashxxhash provides fast non-cryptographic hashing…
permissive · top 1,000 on PyPI
py-multihashEncodes and decodes multihash digests,…
permissive · top 15,000 on PyPI
murmurhashProvides fast MurmurHash2 hashing through…
permissive · top 1,000 on PyPI
siphashProvides a Python implementation of SipHash, a…
permissive · top 15,000 on PyPI