This is a very general question to satisfy a curiosity I've had for years. How is it that NumPy can do the operations it does on an array? How does it work?
If I do
import numpy as np
X = np.linspace(1, 10, 30000000)
for i in range(len(X)):
X[i] = X[i] + 1
the code will finish in 13.214 seconds. And yet NumPy can do this
X = X + 1
# [Finished in 0.707s]
So obviously, NumPy doesn't use simple loops to access each element of the array to perform any given operation. How does a python package, which is itself just python code, access the hardware at such a low level?
I don't have a great understanding of lower level processes, so simple/basic explanations are appreciated.