Introduction
This lesson gives a brief introduction to code vectorization and explains an example using pure Python and NumPy.
What is Code vectorization?
Code vectorization means that the problem you’re trying to solve is inherently vectorizable and only requires a few NumPy tricks to make it faster. Of course, it does not mean it is easy or straightforward, but at least it does not necessitate totally rethinking your problem (as it will be the case in the Problem vectorization chapter). Still, it may require some experience to see where code can be vectorized.
Example
Let’s illustrate this through a simple example where we want to sum up two lists of integers.
Solution 1: Pure Python
One simple way using pure Python is:
Create a free account to view this lesson.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy