CHAPTER
MOTIVATION
I ran a 4 hour tutorial on High Performance Python at EuroPython 2011. I’d like to see the training go to more people so I’ve written this guide. This is based on the official tutorial with some additions, I’m happy to accept updates.
The slides for tutorial are linked on the front page of this document.
If you’d like some background on programming for parallelised CPUs then the Economist has a nice overview article entitled “Parallel Bars” (June 2nd 2011): http://www.economist.com/node/18750706. It doesn’t mention CUDA and OpenCL but the comment thread has some useful discussion. GvR gets a name-check in the article.
I’ll also give myself a quick plug - I run an Artificial Intelligence consultancy (http://MorConsulting.com) and rather enjoy training with Python.
I’d like to note that this report is a summary of work over many weeks preparing for EuroPython. I didn’t perform statistically valid tests, I did however run the timings many times and can vouch for their stability. The goal isn’t to suggest that there is “one best way” to do things - I’m showing you several journeys that takes different routes to faster execution times for this problem.
If you’re curious to see how the stock CPython interpreter compares to other languages like C and JavaScript then see thisbenchmark: http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php -you’ll note that it does rather poorly (up to 100* slower than C!). It also compares poorly against JavaScript V8 which is dynamically typed and interpreted - much like CPython. Playing with comparisons against the JavaScript V8 examples got me started on this tutorial.
To see how CPython, PyPy, ShedSkin, IronPython and Jython compare to other languages (including C and V8) see this benchmark: http://attractivechaos.github.com/plb/ - as shown we can make Python run to 2-6* slower than C with little effort, and the gap with C is shrinking all the time. The flipside of course is that developing with Python is far faster than developing with C!
The following talks were all given at EuroPython, many have links to slides and videos: