Skip to main content

Recordinality.py

A Python implementation of the Recordinality sketch for cardinality estimation and stream sampling. Inspired by C. Scott Andreas’s implementation, but powered by SipHash-2-4 rather than MurmurHash3. In particular, this project uses two other libraries of mine: csiphash and cskipdict.

Installation

pip install recordinality

Usage

You can use the command-line application, which will read lines of text incrementally from stdin, printing the stream’s cardinality (or a random sample) once the pipe is closed:

$ recordinality -k <sketch-size> [-h|--hash-key <hash-key>] [-s|--sample] < input-lines.txt
3574
$ cat input-lines.txt | sort -u | wc -l
3556

SipHash allows the specification of a ‘secret key’ (used here as more of a hash seed); if provided it should be either a 16-char ASCII string or 32-char hexadecimal string.

You can also import the Recordinality class in Python:

>>> from recordinality import Recordinality
>>> sketch = Recordinality(size=512)
>>> for observation in input_observations:
...     sketch.add(observation)
>>> print(sketch.cardinality())
3574
>>> print(sketch.k_sample)
['strife', 'bragging', 'knight?', ...]

Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Metadata

Release files for recordinality 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recordinality 0.0.4
File Size Uploaded Provenance Actions
recordinality-0.0.4.tar.gz 4.7 kB Without provenance Details for recordinality-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for recordinality 0.0.4
File Interpreter ABI Platform Actions
recordinality-0.0.4-py2.py3-none-any.whl Python 2, Python 3 none any Details for recordinality-0.0.4-py2.py3-none-any.whl

Total release size: 11.3 kB

Release files / recordinality-0.0.4.tar.gz

Download URL recordinality-0.0.4.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d554f7c2fc50b94a45d85b9f3c42cf7aa3f1586a37ec89530c4109aa3e50ebfd
BLAKE2b-256 checksum
How to use checksums
9a0ae344b1598fbc0b3f3ce887a9a032e4390c201484fafa33e348ac1fb297ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / recordinality-0.0.4-py2.py3-none-any.whl

Download URL recordinality-0.0.4-py2.py3-none-any.whl
Size 6.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
dfaf61b9a49c7e9d1a05f490b6d8bd6beaf89e14b994dce25157d3670978b54d
BLAKE2b-256 checksum
How to use checksums
6ac1520ebfde0c4d8185b2d668f45890b3c539cccbfc100e084953b718faf163
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for recordinality 0.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page