Skip to main content

functools - Functional Superpowers

lru_cache - Memoization Made Easy

0:00
LearnStep 1/4

What is Memoization?

Memoization: Remember Previous Results

Memoization caches function results so repeated calls with the same arguments return instantly.

The Problem: Slow Recursive Functions

python

The Solution: lru_cache

python

LRU = Least Recently Used. When cache is full, oldest unused entries are removed.