Back to browse
GitHub Repository

Thread-safe Python caching decorator built in Rust. SIEVE eviction, GIL-conditional locking, TTL, async support, cross-process shared memory.

8 starsPython

Warp_cache – SIEVE cache in Rust for Python, 25x faster than cachetools

by tolopalmer·Mar 8, 2026·2 points·0 comments

AI Analysis

●●●BangerWizardryBig Brain

SIEVE cache beats LRU with one-line swap, but only matters if you're bottlenecked on cache.

Strengths
  • SIEVE eviction (NSDI'24) reduces cache misses by 21.6% vs LRU; genuinely novel algorithm
  • Single Rust FFI crossing eliminates Python wrapper overhead; 16-23M ops/s single-threaded
  • Thread-safe out-of-box with GilCell and sharded RwLock; cross-process mmap backend at 9.7M ops/s
Weaknesses
  • Drop-in replacement claim overstates: hashable-only arguments limit migration scope
  • Niche audience: most codebases don't hit cache lookup bottlenecks at this scale
Target Audience

Python developers, systems programmers optimizing cached workloads

Similar To

functools.lru_cache · cachetools · moka

Post Description

I built warp_cache, a thread-safe Python caching decorator backed by a Rust extension (PyO3). It's designed as a drop-in replacement for functools.lru_cache.

The main ideas:

- SIEVE eviction (NSDI'24) instead of LRU — scan-resistant, up to 21.6% fewer cache misses on real workloads - The entire cache lookup happens in a single Rust __call__ — no Python wrapper overhead - Thread-safe out of the box: GilCell under the GIL, sharded RwLock under free-threaded Python (3.13+) - Cross-process shared memory backend via mmap (9.7M ops/s across processes) - 16–23M ops/s single-threaded, 25x faster than cachetools, 1.6x faster than lru_cache + Lock under multi-threaded load

Migration from lru_cache is one line:

-from functools import lru_cache +from warp_cache import cache

-@lru_cache(maxsize=128) +@cache(max_size=128)

Benchmarks and eviction quality comparisons are in the repo.

Similar Projects