Rust-powered HyperLogLog for Python
Project description
rhll
A Rust-powered HyperLogLog cardinality estimator for Python, exposed via PyO3.
Benchmarks
Up to 10M inserts, single-threaded, release build, rhll vs. datasketch
vs. the HLL C extension. Full methodology, machine details, and
count-accuracy numbers: benchmarks/results.md.
| n | rhll | datasketch | HLL |
|---|---|---|---|
| 10,000 | 0.001s | 0.014s | 0.001s |
| 100,000 | 0.005s | 0.123s | 0.009s |
| 1,000,000 | 0.057s | 1.288s | 0.086s |
| 10,000,000 | 0.555s | 12.399s | 0.891s |
rhll is ~22x faster than datasketch at 10M inserts, and slightly faster
than the HLL C extension. count() accuracy is in the same ballpark as
both (0.64% error, vs. 0.77% for HLL and 0.57% for datasketch, on a
10M-item dataset at p=14).
Usage
from rhll import HyperLogLog
h = HyperLogLog(p=12) # default p=12 -> 4096 registers
h.update(b"some-value") # add a single item (bytes)
h.update_str("some-value") # convenience: str -> utf8 -> update
h.count() # -> float, estimated cardinality
h2 = HyperLogLog(p=12)
h2.update(b"other-value")
h.merge(h2) # in-place union, requires matching p
h3 = h.copy() # deep copy
len(h.registers()) # raw register bytes, for debugging/serialization
data = h.to_bytes()
restored = HyperLogLog.from_bytes(data)
[!NOTE] Compatibility with
datasketch.HyperLogLog
update(bytes),count() -> float,merge(other), andcopy()line up directly. Everything else (constructor defaults/args, serialization format, register access,union()) differs, so it's not a drop-in replacement.
Design notes
- Hashing:
xxh3_64(viaxxhash-rust) rather thandatasketch's SHA1, much faster and still well-distributed for this use case. - Precision
p: valid range 4–18,m = 2^pregisters, oneu8per register (no bit-packing in v1). - Merging: sketches must share the same
p; merging mismatched sketches raisesValueErrorrather than silently resizing. - Serialization:
to_bytes()/from_bytes()is[p][registers...], no compression, no versioning beyondp-derived length checks.
Out of scope for v1: HyperLogLog++ (sparse mode), arbitrary hashable objects, distributed merge/persistence beyond raw bytes.
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 Distribution
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 rhll-0.1.0.tar.gz.
File metadata
- Download URL: rhll-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e64ae96c909a32665e2dda9038b74e4440bba1a331b8ea3c446c764078f222ff
|
|
| MD5 |
5b76189410a461780dacd657ba68f908
|
|
| BLAKE2b-256 |
62517fd65428fd3419f0ddb371bb628fb259591be77b45c2e8e41515fb295851
|
Provenance
The following attestation bundles were made for rhll-0.1.0.tar.gz:
Publisher:
release.yml on f4hy/rhll
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rhll-0.1.0.tar.gz -
Subject digest:
e64ae96c909a32665e2dda9038b74e4440bba1a331b8ea3c446c764078f222ff - Sigstore transparency entry: 2146476434
- Sigstore integration time:
-
Permalink:
f4hy/rhll@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/f4hy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Trigger Event:
push
-
Statement type:
File details
Details for the file rhll-0.1.0-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: rhll-0.1.0-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 129.7 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a4fc0e2e9cc2aeb5bdbaf8740f4b8fd700927368ec3baeb676c44b28a93f01a
|
|
| MD5 |
da257c675002f2ff6d26c9c110e6b093
|
|
| BLAKE2b-256 |
84953bd3c07850c14583709b908012323e4dd3405f0b2f7f0cc528875ce8578a
|
Provenance
The following attestation bundles were made for rhll-0.1.0-cp311-abi3-win_amd64.whl:
Publisher:
release.yml on f4hy/rhll
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rhll-0.1.0-cp311-abi3-win_amd64.whl -
Subject digest:
1a4fc0e2e9cc2aeb5bdbaf8740f4b8fd700927368ec3baeb676c44b28a93f01a - Sigstore transparency entry: 2146476442
- Sigstore integration time:
-
Permalink:
f4hy/rhll@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/f4hy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Trigger Event:
push
-
Statement type:
File details
Details for the file rhll-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rhll-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 269.4 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85af97f750318c766e824e8edc1f9529155d6e3165ec410bdd281e20dbd16c95
|
|
| MD5 |
4d7b6b06c11eb7ed5887c684a31791c6
|
|
| BLAKE2b-256 |
fd6d597d61bc802a65435503eec02d2e547c0d00f750f2000805eb9d2c1fdad8
|
Provenance
The following attestation bundles were made for rhll-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on f4hy/rhll
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rhll-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
85af97f750318c766e824e8edc1f9529155d6e3165ec410bdd281e20dbd16c95 - Sigstore transparency entry: 2146476448
- Sigstore integration time:
-
Permalink:
f4hy/rhll@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/f4hy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Trigger Event:
push
-
Statement type:
File details
Details for the file rhll-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: rhll-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 266.1 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9b0c3910b9f43e56e2ee67bc243cb41bc257531cbc25d3c5e7946c1fbaad18e
|
|
| MD5 |
5722fa97c2c82d34c02b534ec70c158b
|
|
| BLAKE2b-256 |
4d331d465ce5e2f11bda2cba518d87f89f691388cb4bfaebe1b4d349fd123d07
|
Provenance
The following attestation bundles were made for rhll-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on f4hy/rhll
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rhll-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
e9b0c3910b9f43e56e2ee67bc243cb41bc257531cbc25d3c5e7946c1fbaad18e - Sigstore transparency entry: 2146476452
- Sigstore integration time:
-
Permalink:
f4hy/rhll@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/f4hy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Trigger Event:
push
-
Statement type:
File details
Details for the file rhll-0.1.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rhll-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 236.2 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
481c01ff7ceadbe71be61b312047a7f8895df14f0801ad1fcd32db77e6aaec2f
|
|
| MD5 |
df9330caf5b45e9eebcdd4702d218929
|
|
| BLAKE2b-256 |
de58e0e850767b2f55c7d62a4726af7c04bd175da90de0c00acca105d358df53
|
Provenance
The following attestation bundles were made for rhll-0.1.0-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on f4hy/rhll
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rhll-0.1.0-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
481c01ff7ceadbe71be61b312047a7f8895df14f0801ad1fcd32db77e6aaec2f - Sigstore transparency entry: 2146476440
- Sigstore integration time:
-
Permalink:
f4hy/rhll@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/f4hy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Trigger Event:
push
-
Statement type:
File details
Details for the file rhll-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rhll-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 234.5 kB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8141bfde7ad7b03a77995a1a47168c557664ef4876d4140bb6e7635ce4b3ed9d
|
|
| MD5 |
36699bbae14e831bf5c1525e0121ace0
|
|
| BLAKE2b-256 |
ce3516fb717c54c75e7fdfaacc4d4e0fc735cadd19b508e03fa9591eb86db051
|
Provenance
The following attestation bundles were made for rhll-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on f4hy/rhll
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rhll-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl -
Subject digest:
8141bfde7ad7b03a77995a1a47168c557664ef4876d4140bb6e7635ce4b3ed9d - Sigstore transparency entry: 2146476457
- Sigstore integration time:
-
Permalink:
f4hy/rhll@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/f4hy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6f3c21bcbfb7b7ab2f9c0926c4d6f3369cee3c0e -
Trigger Event:
push
-
Statement type: