pfutil
Fast HyperLogLog extension for Python 3. The underlying binary representation is compatible with Redis.
This package supports both Python 2.7 and Python 3.3+ (tested with Python 3.13).
#!python3
import redis
from pfutil import HyperLogLog
r = redis.Redis()
r.pfadd('foo', 'a', 'b', 'c')
r.pfadd('bar', 'x', 'y', 'z')
r.pfmerge('bar', 'foo')
assert r.pfcount('foo') == 3
assert r.pfcount('bar') == 6
foo = HyperLogLog.from_bytes(r.get('foo'))
bar = HyperLogLog.from_elements('x', 'y')
bar.pfadd('z')
bar.pfmerge(foo)
assert foo.pfcount() == 3
assert bar.pfcount() == 6
assert r.get('bar') == bar.to_bytes()
Install
Install from PyPI:
pip install pfutil
Install from source:
pip install setuptools
python setup.py install
Usage
HyperLogLog()creates an empty HyperLogLog objectHyperLogLog.from_bytes(b'...')creates a HyperLogLog object from Redis-compatible bytes representationHyperLogLog.from_elements('a', 'b')create a HyperLogLog object from one or more stringsh.pfadd('x')adds one or more strings into this HyperLogLog objecth.pfmerge(other)merges another HyperLogLog objectotherinto thishh.pfcount()returns the cardinality of this HyperLogLog objecth.to_bytes()serializes the HyperLogLog object into Redis-compatible bytes representation
Refer to test.py for some examples.
License
- This
pfutilsoftware is released under the 3-Clause BSD License - The files in
src/redis/are extracted and modified from Redis 6.2.12, which is released under the 3-Clause BSD License as well.
Metadata
Release files for pfutil 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pfutil-1.0.4.tar.gz | 35.5 kB | Without provenance | Details for pfutil-1.0.4.tar.gz |
Release files / pfutil-1.0.4.tar.gz
| Download URL | pfutil-1.0.4.tar.gz |
|---|---|
| Size | 35.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a08176dad56f632e879848180f3caa060dd4bdeb0062cf58411c52c5cf1b480a
|
|
BLAKE2b-256 checksum How to use checksums |
6e0cf0262f2361627021914da42f06f0491ca8c6dcf061d46c0e1b7ad2757042
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.0 CPython/3.10.0
|
Security for pfutil 1.0.4
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.