Skip to main content

Module rotation_cache

Module rotation_cache 

Source
Expand description

Process-wide LRU cache for rotation matrices, keyed by (seed, dim).

Mirrors Python’s functools.lru_cache(maxsize=8) on RotationMatrix._cached_build. The cache stores up to capacity entries and evicts the least-recently-used on insertion. Hits also promote the touched entry to the front of the queue.

The implementation is intentionally minimal — it uses a spin::Mutex<Vec<RotationMatrix>> rather than a proper hash map because the expected capacity is tiny (default 8) and the linear scan fits in a single cache line at that size.

Structs§

RotationCache
A small (seed, dim)-keyed LRU cache over RotationMatrix values.

Constants§

DEFAULT_CAPACITY
Default cache capacity, matching Python’s functools.lru_cache(maxsize=8).