Skip to content

Refactor FrameSet to use range-based storage (fixes #148)#150

Merged
justinfx merged 6 commits intov3from
v3_ranges
Feb 21, 2026
Merged

Refactor FrameSet to use range-based storage (fixes #148)#150
justinfx merged 6 commits intov3from
v3_ranges

Conversation

@justinfx
Copy link
Owner

Implements range-based storage for FrameSet as described in #148.

Storage change: _items (frozenset) + _order (tuple) replaced with _ranges (list of Range objects). Memory reduction of 99.9%+ for typical ranges — a 100k frame range goes from 7.8MB to ~536 bytes.

API compatibility: No breaking changes. .items and .order remain public but now expand lazily with a DeprecationWarning. 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 incorrect True for interleaved ranges like "1-10x2,2-10x2" and crash on empty FrameSet
  • hasSubFrames() — now correctly returns True for decimal notation like "1.0-5.0" where all values happen to be whole numbers
  • Stagger modifier (:) — deduplicated frames within stagger iterations
  • MAX_FRAME_SIZE validation — Stepped (x) and plain ranges now check size mathematically rather than materializing frames

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.
@justinfx justinfx merged commit d265e14 into v3 Feb 21, 2026
11 checks passed
@justinfx justinfx deleted the v3_ranges branch February 21, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant