Metadata-Version: 2.4
Name: larzstruct
Version: 0.1.0
Summary: Data structures the stdlib leaves out: Bloom filter, Trie, union-find (disjoint set), ring buffer. Pure Python, zero dependencies.
Author: larz-scripter
License: MIT
Project-URL: Homepage, https://github.com/larz-scripter/larzstruct
Project-URL: Repository, https://github.com/larz-scripter/larzstruct
Project-URL: Issues, https://github.com/larz-scripter/larzstruct/issues
Keywords: data-structures,bloom-filter,trie,union-find,disjoint-set,ring-buffer,prefix-tree,algorithms,zero-dependency
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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.

```python
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

```bash
pip install larzstruct
```

## Tests

```bash
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](https://github.com/larz-scripter).

## License

MIT © larz-scripter
