Repository navigation
Walk frames directly in FrozenObject._check_init - #2208
Merged
Merged
Conversation
inspect.stack() reads the source file and line for every frame, which made each attribute set inside FrozenDuration.__init__ take milliseconds. Following f_back finds the same __init__/__new__/__setstate__ frame without reading files: creating a FrozenDuration goes from about 12 ms to 0.02 ms. From #2200 by hill (float3). (cherry picked from commit 3f99b5a) AI-assisted (Claude)
float3
added a commit
to float3/music21
that referenced
this pull request
Nov 4, 2026
The frame walk moved to cuthbertLab#2208, which applies it to every FrozenObject.
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.
inspect.stack()reads the source file and line for every frame, which made each attribute set insideFrozenDuration.__init__take milliseconds. Following f_back finds the same__init__/__new__/__setstate__frame without reading files: creating a FrozenDuration goes from about 12 ms to 0.02 ms. (500x speedup!) -- will soon have equally amazing speedups for the creation of initial MeterTerminals and thus, time signatures.From #2200 by hill (float3).
(cherry picked from commit 3f99b5a)
AI-assisted since his was AI-assisted. Claude also helped with the cherry-pick and timing.