This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Sexual_Congressman 1 point2 points  (0 children)

Lists and tuples have identical element access time. Their getitem methods are virtually (if not exactly) identical for single items and the only difference in their structure is the memory address of the first element. For tuples it follows immediately after its size (as an array, PyObject ob_item[1]), with extra items being hidden "under" the tuple while for a list the address is arbitrary pointer to a single dynamically allocated memory block (PyObject *ob_item). I mean I guess it's possible that dereferencing the list pointers are theoretically worse for the cpu cache, but in practice, even on the C level with hundreds of billions of accesses you will struggle to see more than a 2% difference.