How are NumPy arrays advantageous over python lists?
Answer»
The list data structure of python is very highly EFFICIENT and is capable of performing various functions. But, they have severe limitations when it comes to the computation of vectorized operations which deals with ELEMENT-wise multiplication and addition. The python lists also require the information regarding the TYPE of every element which results in overhead as type dispatching code gets executes every time any operation is performed on any element. This is where the NumPy arrays COME into the picture as all the limitations of python lists are handled in NumPy arrays.
Additionally, as the size of the NumPy arrays increases, NumPy becomes AROUND 30x times faster than the Python List. This is because the Numpy arrays are densely packed in the memory due to their homogenous nature. This ensures the memory free up is also faster.