How vectorization speeds up your Python code
Python is not the fastest programming language.
So when you need to process a large amount of homogeneous data quickly, you’re told to rely on “vectorization.”
This leads to more questions:
- What does “vectorization” actually mean?
- When does it apply?
- How does vectorization actually make code faster?
To answer that question, we’ll consider interesting performance metrics, learn some useful facts about how CPUs work, and discover that NumPy developers are working hard to make your code faster.
What “vectorization” means, and when it applies
Let’s say we have a few million numbers in a list or array, and we want to do some mathematical operations on them.
Since we know they are all numbers, and if we’re doing the same operation on all of the numbers, we