Learn functools
Higher-order functions: caching, partial application, decorators and dispatch
functools provides tools that act on or return functions: partial application, reduce, memoisation with cache and lru_cache, cached_property, decorator helpers like wraps, total_ordering for comparisons, and single-dispatch generic functions. They make functional patterns idiomatic in Python and underpin many decorators and frameworks.
Before you start
How deep do you want to go?
1. EssentialsRead and write simple code, do the everyday basics
2. PracticalUse it productively at work, with the usual idioms
3. AdvancedThe less common features, performance and trade-offs
4. ExpertInternals and the edge cases experts know