Skip to content
Latchkey

What Is Memoization?

Memoization is an optimization that stores the output of a pure function keyed by its arguments and returns the cached result when the same inputs recur. The expensive computation runs once per distinct input rather than on every call. It relies on the function being deterministic and free of side effects.

Why it matters

Memoization turns repeated expensive computations into cheap lookups, which is dramatic for overlapping recursive work. The cost is memory for the cache and the assumption that inputs map stably to outputs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →