Repository navigation
Handle iterable operands consistently in set operations - #162
Open
mikamikasuki wants to merge 1 commit into
Open
mikamikasuki wants to merge 1 commit into
mikamikasuki wants to merge 1 commit into
Conversation
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.
IntervalTree documents iterable operands for its set operations, but
intersection(iter(tree))raisesTypeError, and membership checks indifferenceandintersection_updatecan consume an iterator and return incorrect results.difference_update(tree)also raisesRuntimeErrorwhen the operand is the tree itself.Convert non-set operands once before membership queries, preserving existing set operands without copying them. Snapshot the operand for
difference_updatebefore mutation so aliases are safe. Regression tests cover iterators, generators, reusable containers, self-difference updates, and set operands whose iteration is counted.Validation: all 132 tests and doctests pass on CPython 3.12.15 and 3.14.7. Seven regression cases fail before the fix. Separately, 32,000 comparisons against Python set operations pass on CPython 3.9 and 3.14, including mutable interval payloads and self operands; allocation checks confirm that set, frozenset, and IntervalTree operands are not copied by the three query methods. The configured fatal-error flake8 check passes.
Implementation and validation were produced with an AI coding agent.