hashdeque
A deque of characters (any Unicode symbol) that maintains a rolling hash of its contents. Powers of the base are precomputed, so the hash of the current sequence is available in O(1) after each push/pop instead of rehashing everything.
push_front/push_back— O(1)pop_front/pop_back— O(1)hash()of the current contents — O(1)- equality between two
HashDequeinstances — O(1) (compares rolling hashes)
Useful for substring/window matching (Rabin–Karp style), deduplication over a sliding window, and content-defined chunking.
Install
pip install hashdeque
Development setup:
uv venv
uv pip install -e ".[dev]"
Usage
from hashdeque import HashDeque
d = HashDeque()
for ch in "hello":
d.push_back(ch)
print(d.hash()) # rolling-hash fingerprint of "hello"
d.pop_front() # drop 'h'
print(d.hash()) # fingerprint of "ello", computed in O(1)
other = HashDeque("ello")
print(d == other) # True, O(1) comparison
d.verify = True # opt in to exact verification on a hash match
Test
pytest
Layout
hashdeque/
├── pyproject.toml
├── repo_structure.yaml # enforced by the repo-structure pre-commit hook
├── .pre-commit-config.yaml
├── .github/workflows/publish.yml
├── src/hashdeque/
│ ├── __init__.py # public API
│ ├── base.py # BaseHashDeque (ABC) — the contract
│ ├── params.py # HashParams — bases/moduli/inverses
│ ├── deque.py # HashDeque — polynomial double-hash implementation
│ └── py.typed
└── tests/
├── test_base.py
├── test_params.py
└── test_hashdeque.py
Metadata
Release files for hashdeque 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hashdeque-0.0.2.tar.gz | 8.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hashdeque-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.3 kB
Release files / hashdeque-0.0.2.tar.gz
| Download URL | hashdeque-0.0.2.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e71cebb3e8772cef3f549ab0117d788d8e59216b2597d1b931f36ecbf0aa29e3
|
|
BLAKE2b-256 checksum How to use checksums |
8db3025686ad29ffc28d9d19613cfdc089cfa881b6f991ae6d254c69a57e54d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 10, 2026.
Transparency logRelease files / hashdeque-0.0.2-py3-none-any.whl
| Download URL | hashdeque-0.0.2-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3d4ab0ba98ec8e344d2a91c9e3958ec5ee01b5a2df3962648972baaa4bb526a
|
|
BLAKE2b-256 checksum How to use checksums |
c561283c28c935a440c5ddc1b02c8b27212b497bf5389506b923c3b4a97871aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 10, 2026.
Transparency log