Skip to main content

Python bindings for GxHash

Project description

gxhash-py

GitHub PyPi python codecov main.yml

Shows a bar chart with benchmark results.

128-bit hash throughput (MiB/s)

Python bindings for GxHash, a blazingly fast and robust non-cryptographic hashing algorithm.

Highlights

Installation

gxhash is available on PyPI and can be installed via pip.

pip install gxhash

[!IMPORTANT]
This is only possible on systems that support VAES and AVX2 instruction sets.

For the best throughput, you can allow gxhash to use wider registers by passing the MATURIN_PEP517_ARGS environment variable.

MATURIN_PEP517_ARGS="--features hybrid" pip install gxhash

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 gxhash

Usage

Hashing bytes.

from gxhash import GxHash32

def main() -> None:
    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() -> None:
    gxhash = GxHash128(seed=0)
    result = await gxhash.hash_async(b"Hello, world!")

if __name__ == "__main__":
    run(main())

Testing

You can run a comprehensive suite of tests with the following.

cargo test

Project details


Download files

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

Source Distribution

gxhash-0.3.0.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file gxhash-0.3.0.tar.gz.

File metadata

  • Download URL: gxhash-0.3.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gxhash-0.3.0.tar.gz
Algorithm Hash digest
SHA256 be8243bbf945a88332cab0822064285d44b2779e0e4e49c2a7a6c37342466840
MD5 8b9ac52f00ca8001b57057a1c1dd9820
BLAKE2b-256 942f64231bdf5e5378786773a5be68bcd0ebc13221c2178851ea96569728a43a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page