Chapter 8. Performance Python
Don’t lower your expectations to meet your performance. Raise your level of performance to meet your expectations.
— Ralph Marston
When it comes to performance-critical applications two things should always be checked: are we using the right implementation paradigm and are we using the right performance libraries? A number of performance libraries can be used to speed up the execution of
Python code. Among others, you will find the following libraries useful, all of which are presented in this chapter (although in a different order):
Cython, for merging
Cparadigms for static compilation
IPython.parallel, for the parallel execution of code/functions locally or over a cluster
numexpr, for fast numerical operations
Python’s built-in module for (local) parallel processing
Numba, for dynamically compiling
Pythoncode for the CPU
NumbaPro, for dynamically compiling
Pythoncode for multicore CPUs and GPUs
Throughout this chapter, we compare the performance of different implementations of the same algorithms. To make the comparison a bit easier, we define a convenience function that allows us to systematically compare the performance of different functions executed on the same or different data sets:
''' Function to compare the performance of different functions.
func_list : list
list with function names as strings
data_list : list ...