What is `functools.lru_cache` and what are its key parameters?

Python Developer Hard

Python Developer — Hard

What is `functools.lru_cache` and what are its key parameters?

Key points

  • `functools.lru_cache` caches function results based on arguments
  • Key parameters include `maxsize` and `typed`
  • Uses a Least Recently Used eviction strategy
  • Requires hashable arguments for caching
  • Differentiates int/float keys with `typed`

Ready to go further?

Related questions