You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge bitcoin/bitcoin#33313: test/refactor: use test deque to avoid quadratic iteration
75e6984 test/refactor: use test deque to avoid quadratic iteration (Lőrinc)
Pull request description:
Extracted from bitcoin/bitcoin#33141 (comment).
-----
In Python, [list `pop(0)` is linear](https://docs.python.org/3/tutorial/datastructures.html#using-lists-as-queues), so consuming all items in the test results in quadratic iteration.
Switching to `collections.deque` with `popleft()` expresses FIFO intent and avoids the O(n^2) path.
Behavior is unchanged - for a few hundred items the perf impact is likely negligible.
ACKs for top commit:
maflcko:
lgtm ACK 75e6984
theStack:
re-ACK 75e6984
enirox001:
reACK 75e6984
w0xlt:
reACK bitcoin/bitcoin@75e6984
Tree-SHA512: 290f6aeeb33d8b12b7acbbfede7ce0bef1c831a7ab9efc9c3a08c049986572e289cdece0844db908cf198395f574575ce4073c268033bf6dbaadc3828c96c1d8
0 commit comments