Skip main navigation

Course summary

In this video Jussi Enkovaara and Martti Louhivuori summarize the whole course.
Hi, we hope that you have enjoyed the course and learned a lot during these four weeks! Python is very efficient for the programmer, but the dynamic features come with a cost in performance. By restricting the flexibility of Python,
one can get the best out of both worlds: good programmer performance as well as good computer performance.
The four steps for this are:
One: Measure before you optimize. Even though some of the performance aspects can be taken into account when designing the program, the first priority is get the proram working correctly. Premature optimization is the root of all evil! When the program is working as expected, one should use application’s own timers and the cProfile tool to find out where the time is actually spent in the program. Then, one should focus optimizing only these parts.
Two: Use NumPy arrays for numerical data. Python’s built-in data structures are not optimal for number crunching. NumPy offers a static multidimensional array that is perfectly suited for numerical calculations. To get the most performance from Python use NumPy arrays whenever you can.
Three: Use Cython or external code for the most time consuming parts of the program. If all the flebility of Python is not needed, some parts of the application may be greatly speed up by introducing static type definitions and Cythonizing the code. Python provides also different ways for interfacing with code written in another, more performant languages. These languages can then be used for speeding up the most time critical parts of the Python program.
Four: Use MPI for parallel computing. Once you have squeezed out all the performance from a single CPU, or you have run out o the memory in a single CPU, you can gain further speed ups by using multiple CPUs in parallel. The mpi4py package offers a convenient Python interface to parallel computing using the message passing interface. Thanks for attending the course! Happy hacking in Python!

Congratulations for finishing the course!

Please complete the post-course survey and see also the other courses in FutureLearn provided by PRACE.

This article is from the free online

Python in High Performance Computing

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now