Open
Conversation
Extracted from bitcoin#33141 (comment). In Python, list `pop(0)` is linear, so consuming all items is quadratic. Switched to `collections.deque` with `popleft()` to express FIFO intent and avoid the O(n^2) path. Behavior is unchanged; for a few hundred items the perf impact is likely negligible. Ref: https://docs.python.org/3/tutorial/datastructures.html#using-lists-as-queues > While appends and pops from the end of list are fast, doing inserts or pops > from the beginning of a list is slow (because all of the other elements have > to be shifted by one).
b78454f to
70103cd
Compare
97ed557 to
e472e80
Compare
a5d742e to
acc041c
Compare
37a6a6d to
4cdce02
Compare
6a31544 to
acff675
Compare
ed138e2 to
2ccfcf2
Compare
425aeb2 to
9827b14
Compare
dd7a4bd to
521a43c
Compare
7588ad9 to
6db6066
Compare
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.
test PR