10 The Functools Module
Functional programming considers functions to be first-class objects. We’ve seen several higher-order functions that accept functions as arguments or return functions as results. In this chapter, we’ll look at the functools library, which contains some tools to help us implement some common functional design patterns.
We’ll look at some higher-order functions. This extends the material from Chapter 5, Higher-Order Functions. We’ll continue looking at higher-order function techniques in Chapter 12, Decorator Design Techniques, as well.
We’ll look at the following functions in this module:
@cacheand@lru_cache: These decorators can be a huge performance boost for certain types of applications.@total_ordering: This decorator ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access