Comment by Phrodo_00

Comment by Phrodo_00 3 days ago

2 replies

Yeah and no? Python Lists indeed don't make any sort of array-like guarantee, but they're implemented as a vector/autogrowing-array of python object references (but these objects are not guaranteed to be cache-local).

The implementation defines the underlying data structure as PyObject *ob_item

Sn3llius 3 days ago

List access is O(1), which effectively makes them arrays :)

  • Phrodo_00 3 days ago

    Maybe if you don't consider CPU architecture, but most would expect to be able to do loops over Arrays that don't incur in a lot of cache misses, and Python Lists don't do that, since they're actually arrays of pointers to heap memory.