SOARDO
Software Engineer (SDE)pythonintermediate3 interactive MCQs in app

functools Module: partial, lru_cache & reduce

@lru_cache hashable-args & bounded maxsize@wraps metadata preservation in decoratorspartial argument binding

`functools` supplies higher-order helpers cleanly: `@lru_cache(maxsize=...)` (or `@cache`) memoizes pure functions automatically (turning `O(2^n)` top-down DP into `O(n)`!); `partial(fn, fixed_arg)` freezes configuration parameters cleanly; `@wraps(fn)` inside decorators preserves wrapped function `__name__` and `__doc__`!

decorating `def fib(n): return n if n < 2 else fib(n-1) + fib(n-2)` with `@lru_cache(maxsize=128)` drops exponential calls down to `O(n)` with O(1) cache hits!
putting `@lru_cache` on a function receiving unhashable `list`/`dict` arguments raises `TypeError: unhashable type`, or forgetting `maxsize` on unbounded per-user IDs causes memory leaks!
Python functools Module (Official)read ↗functools Module: partial, lru_cache & reduce — Applied Practicepractice ↗Exercism Python Track (Interactive)practice ↗

Practice functools Module: partial, lru_cache & reduce with 3 graded MCQs & written feedback.

Take SOARDO’s free 12-question diagnostic to see how strong you are across your target role and unlock adaptive daily missions.

Test yourself free on SOARDO →View full Software Engineer roadmap

More Software Engineer Study Guides