Python·100 questions

How to cache computations (functools.lru_cache)?

Answer
@lru_cache(maxsize=...).
Works for pure functions.
Arguments must be hashable.
cache_clear() clears cache.
For complex cases — external cache (Redis).
Was this answer helpful?

More questions in this topic

Related questions from other topics