Why NumPy is Fast
Operations on arrays run in compiled code and avoid Python loop overhead. Compare summing a list with a loop and an array with np.sum.
Example
import numpy as np
data = list(range(1000))
arr = np.array(data)
print(sum(data) == arr.sum())
print(arr.dtype, arr.nbytes)Result
True int64 8000
Exercise
Sum an array.
arr.()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.