Optimizations and Improvements

In this chapter, we'll look at some optimizations that we can make to create high-performance functional programs. We will look at the following topics:

  • We'll expand on using the @lru_cache decorator from Chapter 10, The Functools Module. We have a number of ways to implement the memoization algorithm.
  • We'll also discuss how to write our own decorators. More importantly, we'll see how to use a Callable object to cache memoized results.
  • We'll also look at some optimization techniques that were presented in Chapter 6, Recursions and Reductions. We'll review the general approach to tail recursion optimization. For some algorithms, we can combine memoization with a recursive implementation and achieve good performance. ...

Get Functional Python Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.