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.1.tar.gz (11.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: gxhash-0.3.1.tar.gz
  • Upload date:
  • Size: 11.9 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.1.tar.gz
Algorithm Hash digest
SHA256 889f281b922970f4415a723231566a0ffb2151f0cb44a344e747e6159946d40a
MD5 5875359eba7041812a3e5e5019ff3bef
BLAKE2b-256 a8d8b8a0d8e919ecae84bc8e2c740763783dca9889de4ef781ba2299409b8fce

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