Python list is a dynamic array: O(1) index and amortized append, O(n) middle operations
A CPython list is a dynamic array of pointers. Indexing and assignment by index are O(1). append is amortized O(1) because the list occasionally reallocates and copies to grow. pop from the end is O(1). insert or pop at the front or middle is O(n) because elements must shift. Search by value is O(n) because it scans. Slicing is O(k) where k is the slice length.
lst[i], lst[i] = x: O(1)
append(x), pop(): amortized O(1)
insert(i, x), pop(i), remove(x): O(n)
x in lst, index(x): O(n)
Trade-off: use deque for O(1) appends/pops at both ends, and array for compact numeric storage.
Common mistake: saying append is always O(1). It is amortized O(1); a single append can be O(n) during resize.
Version note: overallocation growth factors are CPython implementation details and can change.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience