I will try to explain why NumPy is more powerful and efficient compare with Python List.
First we will see basic definition of the list vs Array programming terminology
Lets see basic data structures arrays and lists
Arrays: are used to store homogeneous data (same data type) of fixed size storing in sequential order in memory
Lists are used to store data of growing in size and storing this data in available place anywhere(not sequential) in the memory.
Almost same logic applies to Python List and NumPy Array. You can see in the below picture, how list and array stores data in memory.
- Able to store different data types in the same list
- Storing each item in random location in the memory
- Good for the scenario where list can grow dynamically
- Inbuilt data type.
- It has more inbuilt functions
- Appending will take less time in O(1) time
- Can store only one data type in an array at any time
- Storing each item is sequential which makes array more effective in processing.
- Good for the scenario where the items are fixed size and same data time
- Need to install external library NumPy
- No extra functions, so it will not more memory store.
- Appending elements will take more time in O(N) time