Add a page detailing the time complexity of operations on built-in types#154363
Open
StanFromIreland wants to merge 4 commits into
Open
Add a page detailing the time complexity of operations on built-in types#154363StanFromIreland wants to merge 4 commits into
StanFromIreland wants to merge 4 commits into
Conversation
Documentation build overview
7 files changed ·
|
picnixz
reviewed
Jul 21, 2026
picnixz
left a comment
Member
There was a problem hiding this comment.
Iteration is, AFAICT, always O(n) so we can group that under a common table. Likewise, getting the length of a sized object is O(1).
I think it's better to keep pythonic exmaples as well. "d[key]" is mucher better than "get item" IMO.
When I read "the non-mtating operations below", it also rings "the opertaions below are all non-mutating". Instead, I suggest to add some * if the opertaion is mutating and explain that at the beginning of the document.
| - *O*\ (*n*) | ||
| * - Get item | ||
| - *O*\ (1) | ||
| * - Set item [1]_ |
Member
There was a problem hiding this comment.
Set item is a mutating operation.
| - *O*\ (1) | ||
| * - Set item [1]_ | ||
| - *O*\ (1) | ||
| * - Delete item |
eendebakpt
reviewed
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inspired by @nedbat's post on Discourse:
The page's location isn't ideal, but we don't have a better place for it currently. We discussed this at the last Docs Community meeting, but didn't come up with a better place to put it, and creating new top level sections is in my opinion, out of scope (as we'd need to move other pages as well). If it's desired we can do it in a future PR.
I spend a while considering how to best present time complexity here, avoiding complexity ;-) The wiki pages splits it into amortised, worst, best and averages cases (each type had a selection of those), but I think that it would be too confusing for readers. As such I give the average case, and put the details in the prose/footnotes.
The numbers are, hopefully, correct, as I don't think I missed any quirks (at least I don't know of any ;-). But I'd appreciate a review from the experts here, maybe Serhiy or Tim could please take a peek?