Skip to main content

One doc tagged with "functools"

View all tags

The `functools` Module: `wraps` and `lru_cache`

We've learned how to create robust decorators that can wrap any function. As we saw, a key part of that pattern is using @functools.wraps to preserve the original function's metadata. The functools module is part of Python's standard library and contains powerful tools for working with higher-order functions (functions that act on or return other functions).