3 ms·
Many of these things are annoying, but I wanna check something.... Lists in python are called lists because they're linked lists right? They are not called arr
by aeturnum 4y ago
Many of these things are annoying, but I wanna check something....
Lists in python are called lists because they're linked lists right? They are not called arrays because they are a different data structure.
Edit: Well TIL! Thanks everyone.
- raymondh 4y agoNope.
- lights0123 4y agoNo, lists are implemented in CPython as an regular, contiguous array of PyObject. There is an array library (https://docs.python.org/3/library/array.html https://docs.python.org/3/library/array.html) for more efficient storage, comparable to JS's Uint8Array and friends.
- LightHugger 4y agolists are arrays with different data types allowed per index
- pdonis 4y ago> Lists in python are called lists because they're linked lists right? No. At the C level in the interpreter they are arrays of object pointers. > They are not called arrays because they are a different data structure. No. They're not called arrays because Python uses the name "array" for something else: https://docs.python.org/3/library/array.html https://docs.python.org/3/library/array.html
- hiq 4y agoHow widely are Python arrays used in practice?
- pdonis 4y agoI haven't had much occasion to use them. I suspect that most use cases nowadays where the speed advantage is needed involve numerical computing where the user is probably using a library like numpy or scipy and will use their array implementation, not the built-in Python one. However, arrays have been around in Python since very early on, when those other numerical libraries didn't exist, so the array built-in might have gotten more use then.
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]