I understand that a list is different from an array. But still, O(1)? That would mean accessing an element in a list would be as fast as accessing an element in a dict, which we all know is not true. My question is based on this document:
list ---------------------------- | Operation | Average Case | |-----------|--------------| | ... | ... | |-----------|--------------| | Get Item | O(1) | ----------------------------
and this answer:
Lookups in lists are O(n), lookups in dictionaries are amortized O(1), with regard to the number of items in the data structure.
If the first document is true, then why is accessing a dict faster than accessing a list if they have the same complexity?
Can anybody give a clear explanation on this please? I would say it always depends on the size of the list/dict, but I need more insight on this.