Prev: - | Next: Array construction
- (a) Speed of code execution: A list is a flexible collection of various objects (integers, floats, strings, other objects, etc.). This flexibility however requires system memory and time for implementing various processes necessary for list construction and management. An array instead is a much more compact (although less flexible) object minimizing the code execution time and required system memory.
- (b) Vectorization: arrays are equipped with lots of functions that support vectorization, which is the ability to apply operations (addition, multiplication, etc.) on entire arrays instead of single numbers (scalars). Thus, many operations that would require loops if using lists are expressed in one single line of code with numpy arrays.
. Free learning material
. See full copyright and disclaimer notice