[Performance] PyScene::update does GetAttrString("update") every frame even when unoverridden #343
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#343
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
PyScene::updatecallsPyObject_GetAttrString((PyObject*)self, "update")every frame (src/PySceneObject.cpp:405), a string-keyed dict lookup, even for scenes whose Python subclass does not overrideupdate.Proposed fix
Cache whether the subclass overrides
update(a bool flag resolved once, or a cached bound-method reference), and skip the lookup when it doesn't. The codebase already uses this pattern on the hover hot path —PyScene.cpp:361checksis_python_subclass"to avoid overhead on hot path" before calling into Python. Apply the same guard here.Benchmark
Measure per-frame scene-update overhead headless with a plain (non-overriding) scene, before/after. Add to
tests/benchmarks/.Related: #331.