Conversation
Replace fully-expanded _items (frozenset) and _order (tuple) with a compact list of Range objects. Memory reduction of 99.9%+ for typical ranges (100k frames: 7.8MB -> ~536 bytes). Bug fixes: - isConsecutive(): rewrite as O(n) range-based algorithm; fixes incorrect True for interleaved ranges and IndexError on empty FrameSet - hasSubFrames(): correctly returns True for decimal notation like 1.0-5.0 where normalizeFrame collapses values to integers before storage - Stagger modifier: deduplicate frames across stagger iterations - MAX_FRAME_SIZE check: calculate size mathematically for x and plain ranges instead of materializing all frames API compatibility: no breaking changes. .items and .order remain public with DeprecationWarning. All 181 existing tests pass.
This was referenced Feb 20, 2026
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.
Implements range-based storage for
FrameSetas described in #148.Storage change:
_items(frozenset) +_order(tuple) replaced with_ranges(list ofRangeobjects). Memory reduction of 99.9%+ for typical ranges — a 100k frame range goes from 7.8MB to ~536 bytes.API compatibility: No breaking changes.
.itemsand.orderremain public but now expand lazily with aDeprecationWarning. All 181 existing tests pass.Performance trade-offs: All operations remain sub-millisecond for typical frame ranges. Iteration over 5k frames takes ~0.47ms vs ~0.10ms previously. First equality check triggers a one-time normalization (0.33ms vs 0.02ms); subsequent checks are faster than v3 (~0.0003ms) due to cached normalized range comparison.
Bug fixes included:
isConsecutive()— rewrote as range-based algorithm with no frame expansion; fixes incorrectTruefor interleaved ranges like"1-10x2,2-10x2"and crash on emptyFrameSethasSubFrames()— now correctly returnsTruefor decimal notation like"1.0-5.0"where all values happen to be whole numbers:) — deduplicated frames within stagger iterationsMAX_FRAME_SIZEvalidation — Stepped (x) and plain ranges now check size mathematically rather than materializing frames