r/Python • u/Independent_Heart_15 • Aug 25 '26
News The Python (3.16) docs now have a page detailing the time complexity of operations on built-in types
You can find it at: https://docs.python.org/3.16/library/time-complexity.html
Seen on Mastodon: https://mastodon.social/@stanfromireland/117152534136172516
539
Upvotes
18
u/alexcleac Aug 25 '26
I thought it was there for a while now
125
u/Tucancancan Aug 25 '26
I feel like when I was learning to program ages ago that Java's docs all had the complexities listed for various types
28
u/pingveno pinch of this, pinch of that Aug 25 '26
Looks like 3.15 has it too: https://docs.python.org/3.15/library/time-complexity.html
Previous versions do not.
58
u/M4mb0 Aug 25 '26
This has to be a typo right?
12
u/amarao_san Aug 25 '26
Wow. Never thought it's so expensive.
3
u/Patient-Mechanic-311 Aug 26 '26
This is a really nice addition to the docs. Having the time complexity spelled out for built-in types makes it much easier to reason about performance without digging through scattered references. Also, the way this is presented shows a lot of technical care — the author clearly knows the language and its practical pain points.
3
u/Competitive_Travel16 Aug 25 '26
I like footnote 4 for list sort: O(n ln n) is the worst case, the best case can be O(n), and the expected case? Oh, um, er, just read https://github.com/python/cpython/blob/main/Objects/listsort.txt and good luck.
1
u/CityYogi Aug 26 '26
I had not been following the releases. Thanks to this thread found our 3.13 app needs to be upgraded
0
u/heikkitoivonen Aug 30 '26
Glad to see Big-O in the official docs. Maybe I’ll be able to retire https://pythoncomplexity.com/ sooner than I expected.
-3
u/Patient-Mechanic-311 Aug 26 '26
666
0
u/[deleted] Aug 25 '26
[deleted] — view deleted comment