cache-recursive-calls
Installation
SKILL.md
cache-recursive-calls
When to Use
- Recursive function computes same inputs multiple times
- Overlapping subproblems (DP)
- Fibonacci-like recurrence relations
- Tree/graph traversal with revisits
- Expensive pure functions called repeatedly
When NOT to Use
- Function has side effects
- Inputs aren't hashable
- Cache would grow too large
- Each input computed only once
The Pattern
Use @functools.cache (Python 3.9+) or @functools.lru_cache(None) to memoize.