← TechnologyThe essentials of

Lru_cache: reusing calculations with bounded storage

Publisher: ResumeMaker • 1 source

Published: 22 Oct 2026 16:11 · Updated: 22 Oct 2026 16:11

AI source check: 22 Oct 2026 14:04. This is not editorial approval.

In a few sentences

In brief

functools.lru_cache stores call results by argument values. maxsize limits the retained entries, and the arguments must be hashable.

Useful to know

functools.lru_cache stores call results by argument values. maxsize limits the retained entries, and the arguments must be hashable. [1]

It suits repeatable calculations rather than automatically fitting functions with side effects. Changing external data does not refresh an old result by itself. Define when the cache is cleared and whether retained values still suit the task.

Sources

For further detail and to check the information:

  1. [1] functools — Higher-order functions and operations on callable objects — Python 3.12.15 documentation ↗