Collections Module¶
The rite.collections package provides higher-level data structures and
collection utilities that extend the Python standard library.
Overview¶
This section gives a high-level overview of the collections infrastructure. Detailed APIs for each submodule are available on their dedicated pages below.
Submodules¶
- Cache: LRU, LFU, and TTL caches.
- Buffer: Circular and sliding window buffers.
- Dictionary Utilities: Deep dictionary helpers.
- List Utilities: Advanced list operations.
- Tree Structures: Trees, binary trees, and tries.
Examples¶
from rite.collections import (
lru_cache,
circular_buffer,
dict_deep_get,
list_chunk
)
# LRU Cache
cache = lru_cache(maxsize=100)
# Circular Buffer
buffer = circular_buffer(capacity=10)
buffer.append(1)
buffer.append(2)
# Deep dictionary access
data = {"a": {"b": {"c": 42}}}
value = dict_deep_get(data, ["a", "b", "c"]) # 42
# Chunk list
items = [1, 2, 3, 4, 5, 6]
chunks = list_chunk(items, 2) # [[1, 2], [3, 4], [5, 6]]