Chapter 5. High-Performance and Parallel Computing
As an interpreted and dynamic language, Python is slower than C, C++, or Fortran, especially when using loops. Thus, numerical algorithms written in pure Python are generally too slow to be useful. As we saw in Chapter 3, Numerical Computing with NumPy, NumPy solves this problem by offering fast vector computations on array structures.
Some algorithms cannot be easily vectorized with NumPy. Using Python loops is then required. The two main solutions to make loops fast in a context of numerical computing are the following: using a JIT compiler like Numba, or using Cython to translate these loops to C.
Another general method for making computations faster is to distribute jobs across the multiple processors on a multicore computer.
In this chapter, we will cover all of these topics:
- Accelerating Python code with Numba
- Writing C in Python with Cython
- Distributing tasks on several cores with IPython.parallel
- Further high-performance computing...