Back
Close

Journey to Master Python (WIP)

ageekymonk
34.1K views

Functools module

Memoization

Functools module supports memoization through lru_cache decorator. This way you dont need to write memoization code.

In the example adding the decorator @lru_cache does the needful. You can also see the cache details with cache_info

lru_cache Decorator
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io