eBook Review: Python High Performance Programming

Last year, Packt Publishing asked me to be a technical reviewer for a book called Python High Performance Programming by Gabriele Lanaro. It was published in December, 2013. For those of you with short attention spans, I give you my short review:

Quick Review

  • Why I picked it up: I got it for free, but I would have picked it up because the subject matter interested me
  • Why I finished it: This book had lots of interesting tips that made me want to keep reading it
  • I’d give it to: Someone who wants to learn about optimizing their code

If that whetted your appetite, be sure to click through for the full review!

Book Formats

This book can be bought in paperback, PDF, epub and Kindle formats.


Full Review

The way this book is laid out, it reminds me of Packt Publishing’s Instant series in that this is one of their shorter books with only 4 chapters and 108 pages. The first chapter is about benchmarking and profiling. It talks about using Python’s cProfile, the dis module and the memory_profiler. I found this chapter to be extremely interesting. While I knew about several of the items that the chapter mentioned, it contained enough new information in it that it left my brain brimming with profiling ideas.

In chapter two, we learn about fast arrays using NumPy. This is a bit odd as I don’t normally think of adding performance by adding a scientific Python package to my system. However, it made sense if you do a lot of work with arrays. It also discusses a particle simulator (neat!) and using numexpr, a fast numerical expression evaluator for NumPy. I personally don’t do a lot of work with arrays right now, but for those that do, this chapter may be of interest.

Chapter three delves into the world of Cython. The idea here is to use Cython to speed up your regular Python code by using static types, working with C arrays / pointers, memoryviews, etc. I thought it was really cool how you could improve a **for** loop’s speed with just a couple of tweaks that basically changed it into a C for loop. It has plenty of examples. Personally, I’d like to see a book written just on the topic of Cython.

For Chapter four, the author digs into parallel processing. The focus of this chapter is using the multiprocessing module that comes with Python. There is also a section about using IPython parallel. You can read a bit about that topic here. The last section of this chapter talks about using Cython with OpenMP to allow parallel processing in Cython.

The only issue I really had with this book is that it’s a bit too short. I would have liked to have read a full sized text on the subject. In any case, for those of you that need ideas for speeding up your code, I think this book will get you started.

high_performance_py.png

Python High Performance Programming

by Gabriele Lanaro

Amazon

Packt Publishing


Other Book Reviews

http://www.packtpub.com/python-high-performance-programming