Chapter 21. The Benchmarking Interlude

Now that we know about coding functions and iteration tools, we’re going to take a short side trip to put both of them to work. This chapter closes out the function part of this book with a larger case study that times the relative performance of the iteration tools we’ve met so far.

Along the way, this case study surveys Python’s code timing tools, discusses benchmarking techniques in general, and allows us to explore code that’s a bit more realistic and useful than most of what we’ve seen up to this point. We’ll also measure the speed of current Python implementations—a data point that may or may not be significant, depending on the type of code you write.

Finally, because this is the last chapter in this part of the book, we’ll close with the usual sets of “gotchas” and exercises to help you start coding the ideas you’ve read about. First, though, let’s have some fun with a tangible Python application.