Skip to main content

larzstruct

Data structures the standard library leaves out. Pure Python, zero deps.

A probabilistic set (Bloom filter), a prefix tree (Trie), a union-find (disjoint set), and a fixed-size ring buffer — the ones you reach for often enough to want, without re-implementing them each time.

from larzstruct import BloomFilter, Trie, DisjointSet, RingBuffer

bf = BloomFilter(capacity=10000, error_rate=0.01)
bf.add("alice"); "alice" in bf              # True (never a false negative)

t = Trie(); t.insert("apple"); t.insert("app")
t.starts_with("ap"); t.keys("ap")            # ['app', 'apple']

ds = DisjointSet(); ds.union(1, 2); ds.connected(1, 2)   # True

rb = RingBuffer(3); rb.extend([1, 2, 3, 4]); rb.to_list()  # [2, 3, 4]

What's inside

  • BloomFilter — space-efficient set membership; computes the optimal bit-array size and hash count from your capacity + target error_rate. No false negatives; false positives stay under the target. Great for "have I seen this?" at scale.
  • Trie — insert, in, starts_with, and keys(prefix) for fast prefix queries and autocomplete.
  • DisjointSet (union-find) — union/find/connected/groups with path compression and union by rank. Connectivity, clustering, cycle detection.
  • RingBuffer — fixed capacity, appends past capacity overwrite the oldest; iterates oldest-first, with latest(n), is_full(), to_list().

Zero dependencies — pure standard library.

Install

pip install larzstruct

Tests

python -m unittest discover -s tests -v   # 17 tests

The Larz stack

One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.

License

MIT © larz-scripter

Metadata

Release files for larzstruct 0.1.0

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

Source distribution (sdist)

Source distribution for larzstruct 0.1.0
File Size Uploaded Provenance
larzstruct-0.1.0.tar.gz 5.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for larzstruct 0.1.0
File Interpreter ABI Platform
larzstruct-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.3 kB

Release files / larzstruct-0.1.0.tar.gz

Download URL larzstruct-0.1.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
03c0cd63e0e5af30ea674ca2f5827e70838cc27b7d29c7b5e49b4508eed9e8f1
BLAKE2b-256 checksum
How to use checksums
5fe9abdf78a4ed83b7fbfc10ddc7cf3ae35f5d1d993562564a7e09d7ebc53f79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / larzstruct-0.1.0-py3-none-any.whl

Download URL larzstruct-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
376d7adf1c6f0103661fd5222aaf724d2513a75d0451e4c39d0964319b59d351
BLAKE2b-256 checksum
How to use checksums
9100a173acee6e36ca43a1d48252afd828db79b8a1f7fe48bbd3c07f4d5a0944
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for larzstruct 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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