Python bindings for GxHash, a blazingly fast and robust non-cryptographic hashing algorithm.
- Blazingly Fast: Minimal-overhead binding to leverage the full speed of GxHash.
- Zero Python: Pure Rust backend with zero additional Python runtime overhead.
- Async-Ready: Tokio-powered async hashing for fast and efficient concurrency.
- Fully Typesafe: Predictable, clean API with complete type safety.
gxhash is available on PyPI and can be installed via pip.
pip install gxhashFor best performance, you can enable the hybrid by passing the following build-args to the --config-settings flag.
pip install gxhash --config-settings build-args="--features hybrid"By default, gxhash uses your system's vectorisation features. You can disable this by setting the relevant RUSTFLAGS.
RUSTFLAGS="-C target-cpu=x86-64 -C target-feature=+aes,+avx2" pip install gxhashIf you are using uv, you can enable the hybrid feature by adding the following config-settings under the tool.uv section.
[tool.uv]
config-settings = { build-args = "--features hybrid" }uv add gxhashHashing bytes.
from gxhash import GxHash32
def main():
gxhash = GxHash32(seed=0)
result = gxhash.hash(b"Hello, world!")
if __name__ == "__main__":
main()Hashing bytes asynchronously.
from asyncio import run
from gxhash import GxHash128
async def main():
gxhash = GxHash128(seed=0)
result = await gxhash.hash_async(b"Hello, world!")
if __name__ == "__main__":
run(main())