Skip to content

Walk frames directly in FrozenObject._check_init - #2208

Merged
mscuthbert merged 1 commit into
masterfrom
frozen-object-check-init
Nov 3, 2026
Merged

mscuthbert merged 1 commit into
masterfrom
frozen-object-check-init

Conversation

@mscuthbert

@mscuthbert mscuthbert commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

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. (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.

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)
@mscuthbert
mscuthbert merged commit b937a8a into master Nov 3, 2026
11 checks passed
@mscuthbert
mscuthbert deleted the frozen-object-check-init branch November 3, 2026 01:09
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 93.812%. remained the same — frozen-object-check-init into master

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants