Python CLI and API scaffolding for PerfectHash.
Project description
PerfectHash Python
This is the supported Python package for PerfectHash.
The current goal is to build a modern, testable Python package and migrate useful legacy functionality over in small, verifiable slices.
Status
There are currently two distinct Python-facing workflows:
- Offline CLI workflow via
ph create - Offline CLI workflow via
ph bulk-create - In-process programmatic workflow via
build_table()
These are intentionally different:
ph createmaps to the existing offline C creation workflow and is meant to generate offline table artifacts.ph bulk-createmaps to the existing offline C bulk-create workflow and is meant to generate offline tables for a directory of key files.build_table()is the in-process native runtime path for code that wants to create and use a table from within Python.
CLI
Show the current CLI surface with:
env -u PYTHONPATH uv run python -m perfecthash --help
env -u PYTHONPATH uv run python -m perfecthash create --help
env -u PYTHONPATH uv run python -m perfecthash bulk-create --help
The current ph create command translates modern Python-style options into
the existing PerfectHashCreate contract, then shells out to the C create
binary.
Example dry run:
env -u PYTHONPATH uv run python -m perfecthash create \
keys/example.keys \
out \
--hash-function MultiplyShiftR \
--graph-impl 3 \
--create-binary /home/trentn/src/perfecthash/build/bin/PerfectHashCreate \
--dry-run
Current output:
/home/trentn/src/perfecthash/build/bin/PerfectHashCreate keys/example.keys out Chm01 MultiplyShiftR And 0 --GraphImpl=3
Useful control flags:
--emit-c-argvprints the abstract translated C argv.--dry-runprints the resolved executable command.--create-binarypoints explicitly at the offline create binary.
There is also an initial ph bulk-create command with the same execution
model for the offline bulk-create workflow.
Discovery now prefers installation-oriented locations first:
- package-bundled native dirs such as
perfecthash/_native/binandperfecthash/_native/lib - explicit install-prefix env vars like
PERFECTHASH_PREFIX - the active Python / conda prefix (
sys.prefix,CONDA_PREFIX) - development-tree fallbacks last
For now, you may still need to pass --create-binary or set
PERFECTHASH_CREATE_BINARY, but the package no longer assumes a source-tree
build first.
Packaging
The current packaging split is:
- standalone release wheels bundle native assets under
perfecthash/_native/ - conda installs the Python package unbundled and relies on the matching native
perfecthash-fullpackage in the same prefix
Python package versions are resolved from the same release/tag inputs as the native build so tagged releases ship matching native and Python versions.
Programmatic API
The current in-process runtime entry point is build_table():
from perfecthash import build_table
with build_table([1, 3, 5, 7, 11, 13, 17, 19], hash_function="MultiplyShiftR") as table:
print(table.backend)
print(table.hash_function)
print(table.key_count)
print(table.index(13))
Current output from a local verification run:
rawdog_jit
MultiplyShiftR
8
5
This path keeps the hot table implementation native and is the foundation for the future programmatic Python API.
Curated Hash Functions
The currently supported curated set is:
MultiplyShiftRMultiplyShiftRXMulshrolate1RXMulshrolate2RXMulshrolate3RXMulshrolate4RX
These names are preserved exactly as-is in the Python CLI and API.
More Detail
See docs/python-cli-and-api.md for a fuller overview of the current Python package direction.
Development
Install the baseline developer environment with:
env -u PYTHONPATH uv sync
For editable installs with native artifacts from this checkout, use the repo-local install prefix helper:
./scripts/install-python-native-prefix.sh
export PERFECTHASH_PREFIX="$PWD/.perfecthash-prefix"
env -u PYTHONPATH uv sync
This keeps Python editable while making binary/library discovery behave more like a packaged install.
Run the baseline checks with:
env -u PYTHONPATH uv run pytest
env -u PYTHONPATH uv run ruff check python_src python_tests
env -u PYTHONPATH uv run black --check python_src python_tests
env -u PYTHONPATH uv run mypy
Install the git hook with:
env -u PYTHONPATH uv run pre-commit install
The explicit env -u PYTHONPATH is there to avoid inheriting any legacy
PerfectHash Python path overrides from an existing shell session.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tpn_perfecthash-0.74.0-py3-none-win_amd64.whl.
File metadata
- Download URL: tpn_perfecthash-0.74.0-py3-none-win_amd64.whl
- Upload date:
- Size: 619.1 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26cb71bcd29d1fe91ce884536efef90fee9fa83cf689de726379f48dd6fd41b5
|
|
| MD5 |
43caed5510ad2260b5e6c7b75f978285
|
|
| BLAKE2b-256 |
3a3a9bc09534882ca1fffe277e809bdd2cbefec6e8baf115b1a74a4fe7633cc2
|
Provenance
The following attestation bundles were made for tpn_perfecthash-0.74.0-py3-none-win_amd64.whl:
Publisher:
release.yml on tpn/perfecthash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tpn_perfecthash-0.74.0-py3-none-win_amd64.whl -
Subject digest:
26cb71bcd29d1fe91ce884536efef90fee9fa83cf689de726379f48dd6fd41b5 - Sigstore transparency entry: 1100569663
- Sigstore integration time:
-
Permalink:
tpn/perfecthash@186aa3f013e4af6a492839435ff7539f2763e52b -
Branch / Tag:
refs/tags/v0.74.0 - Owner: https://github.com/tpn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@186aa3f013e4af6a492839435ff7539f2763e52b -
Trigger Event:
push
-
Statement type:
File details
Details for the file tpn_perfecthash-0.74.0-py3-none-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: tpn_perfecthash-0.74.0-py3-none-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 3, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a04d11276405aef033914e1ca4af4a2142697d487c9baa2fb194b713e94b3b46
|
|
| MD5 |
5edefc6dcd7fedd90f6ea54d4e5620b1
|
|
| BLAKE2b-256 |
2e28e17fd92fb1e38889a468bc299bee61c07ab4704852332551c483c8a10297
|
Provenance
The following attestation bundles were made for tpn_perfecthash-0.74.0-py3-none-manylinux_2_39_x86_64.whl:
Publisher:
release.yml on tpn/perfecthash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tpn_perfecthash-0.74.0-py3-none-manylinux_2_39_x86_64.whl -
Subject digest:
a04d11276405aef033914e1ca4af4a2142697d487c9baa2fb194b713e94b3b46 - Sigstore transparency entry: 1100569507
- Sigstore integration time:
-
Permalink:
tpn/perfecthash@186aa3f013e4af6a492839435ff7539f2763e52b -
Branch / Tag:
refs/tags/v0.74.0 - Owner: https://github.com/tpn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@186aa3f013e4af6a492839435ff7539f2763e52b -
Trigger Event:
push
-
Statement type:
File details
Details for the file tpn_perfecthash-0.74.0-py3-none-manylinux_2_39_aarch64.whl.
File metadata
- Download URL: tpn_perfecthash-0.74.0-py3-none-manylinux_2_39_aarch64.whl
- Upload date:
- Size: 964.4 kB
- Tags: Python 3, manylinux: glibc 2.39+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60968535bf32871ad7d593241b998a4868dd2d15b091d1eee589d65dd2ddd27b
|
|
| MD5 |
bcb0a4aee2e3da6816254835eba7823c
|
|
| BLAKE2b-256 |
9686f61842e8dfbcb6c340a43cdbf2f0d90f5ab59be83279f4df971d83545e1b
|
Provenance
The following attestation bundles were made for tpn_perfecthash-0.74.0-py3-none-manylinux_2_39_aarch64.whl:
Publisher:
release.yml on tpn/perfecthash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tpn_perfecthash-0.74.0-py3-none-manylinux_2_39_aarch64.whl -
Subject digest:
60968535bf32871ad7d593241b998a4868dd2d15b091d1eee589d65dd2ddd27b - Sigstore transparency entry: 1100569742
- Sigstore integration time:
-
Permalink:
tpn/perfecthash@186aa3f013e4af6a492839435ff7539f2763e52b -
Branch / Tag:
refs/tags/v0.74.0 - Owner: https://github.com/tpn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@186aa3f013e4af6a492839435ff7539f2763e52b -
Trigger Event:
push
-
Statement type:
File details
Details for the file tpn_perfecthash-0.74.0-py3-none-macosx_15_0_x86_64.whl.
File metadata
- Download URL: tpn_perfecthash-0.74.0-py3-none-macosx_15_0_x86_64.whl
- Upload date:
- Size: 827.7 kB
- Tags: Python 3, macOS 15.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aaf76008602372ab048c5df287b6e12766534e3826c9e3725ebfa198c72a54f
|
|
| MD5 |
e27abec0c3daea84e29f5b85f9e54e7e
|
|
| BLAKE2b-256 |
99313fabd2eef0cd1eb7b83fb90b797538cca82917e4b513e11527bf887ddfaf
|
Provenance
The following attestation bundles were made for tpn_perfecthash-0.74.0-py3-none-macosx_15_0_x86_64.whl:
Publisher:
release.yml on tpn/perfecthash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tpn_perfecthash-0.74.0-py3-none-macosx_15_0_x86_64.whl -
Subject digest:
6aaf76008602372ab048c5df287b6e12766534e3826c9e3725ebfa198c72a54f - Sigstore transparency entry: 1100569824
- Sigstore integration time:
-
Permalink:
tpn/perfecthash@186aa3f013e4af6a492839435ff7539f2763e52b -
Branch / Tag:
refs/tags/v0.74.0 - Owner: https://github.com/tpn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@186aa3f013e4af6a492839435ff7539f2763e52b -
Trigger Event:
push
-
Statement type:
File details
Details for the file tpn_perfecthash-0.74.0-py3-none-macosx_14_0_arm64.whl.
File metadata
- Download URL: tpn_perfecthash-0.74.0-py3-none-macosx_14_0_arm64.whl
- Upload date:
- Size: 800.7 kB
- Tags: Python 3, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c55b8aab202c2d71492285ba30a012a9934c3424264a7826299b96ff3ac44c2d
|
|
| MD5 |
a62083b5aa3958c2d0e9f2e4ea85bf70
|
|
| BLAKE2b-256 |
b4b3446d73a7b2e89fb5bc9c62c808b250886c19a77c8e174d26f21dc4ea7829
|
Provenance
The following attestation bundles were made for tpn_perfecthash-0.74.0-py3-none-macosx_14_0_arm64.whl:
Publisher:
release.yml on tpn/perfecthash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tpn_perfecthash-0.74.0-py3-none-macosx_14_0_arm64.whl -
Subject digest:
c55b8aab202c2d71492285ba30a012a9934c3424264a7826299b96ff3ac44c2d - Sigstore transparency entry: 1100569580
- Sigstore integration time:
-
Permalink:
tpn/perfecthash@186aa3f013e4af6a492839435ff7539f2763e52b -
Branch / Tag:
refs/tags/v0.74.0 - Owner: https://github.com/tpn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@186aa3f013e4af6a492839435ff7539f2763e52b -
Trigger Event:
push
-
Statement type: