Extracted from #33141 (review).
In Python, list pop(0)
is linear, 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.