Repository navigation
Conversation
fhgffy
marked this pull request as ready for review
October 2, 2026 13:00
This branch has not been deployed
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.
interleavecan silently drop values from unrelated inputs when the same iterator occupies more than one input slot:If the shared iterator starts empty, the entire
[10, 11]input is lost. The removal loop uses iterator identity to find the exhausted slot again, so another occurrence of that iterator ends the retained cycle too early.Wrap each input occurrence in a distinct single-input
itertools.chain. This preserves shared consumption while giving each slot its own identity. The existing cycle/removal algorithm and inner loop remain intact, including support for infinite inner and outer inputs.The three regression tests cover adjacent and separated shared slots, empty and odd-length shared inputs, and infinite inputs. All three fail before the change and pass afterward.
Validation on Linux:
pytest bench/ -q: 19 passedpycodestylecommand andgit diff --check: passedPerformance tradeoff: the wrapper adds per-input overhead, and timings vary by workload. One local median-of-five sample for ten streams of 1,000 elements (
number=200) took 0.0751 s before and 0.0930 s after, about 24% slower. Uneven-length and many-short-stream samples were close to baseline (ratios 0.963 and 0.995). This fixes data loss but does not claim performance neutrality.