Python docs detail time complexity of built-in list, tuple operations
The official CPython documentation lays out Big O complexity tables for core operations on built-in types like list and tuple, covering actions such as append, insert, slicing, concatenation, and membership testing. It notes these figures apply specifically to CPython's exact built-in types, and that subclasses or other Python implementations may behave differently.
GoKawiil's interpretation of the reporting above, not reported fact.
Understanding these complexity guarantees helps developers choose the right data structure for performance-sensitive code, such as favoring collections.deque over list when frequent insertions or deletions happen at both ends. This reference reduces guesswork and prevents subtle performance bugs in production Python code.
- List append and indexing are O(1), but insert/delete near the front cost O(n)
- Tuples are immutable, so copying and most operations avoid extra overhead
- Performance characteristics documented apply to CPython specifically, not all Python implementations
Python Cookbook by David Beazley — If you're digging into the cost of list inserts versus deque appends, this classic O'Reilly cookbook is full of recipes that show which data structure to reach for and why. It pairs perfectly with CPython complexity tables by turning Big O trivia into practical, idiomatic code.
See Python Cookbook by David Beazley on Amazon → Affiliate link — we may earn a commission on purchases, at no extra cost to you. Product picked by AI based on this article; it is not a tested recommendation.Source: docs.python.org, 2026-08-25
Published there as: “Time complexity of operations on Python's built-in types”
Read the original report → The summary and analysis above are GoKawiil's own, written from reporting by the source above. Facts and quotes belong to the original publisher.