+ 1

Arrays vs lists

What is the difference between an array and a list?

20th Jan 2019, 7:51 PM
Julian
Julian - avatar
1 Antwort
0
The question isn't well differentiated, as there is a lot of details missing, what exactly you want to understand. In general, arrays and lists are the same thing (mostly), as far as python is concerned. Yet, they are very different things in other programming languages. An array in c for example is just a consecutive block of memory, segmented into equally sized chunks. A list is a data type that can dynamically grow and shrink and has quite easy methods to append and insert new elements. It's more versatile but also not as fast as an array. The numpy array is likely to be based upon C arrays, I don't know that for sure tho. The main difference between ndarray and list is that they have a different API and therefore, the ndarray can be used for different things, especially in numpy methods.
16th Aug 2022, 8:43 PM
Fynn Nix
Fynn Nix - avatar