Fast path for .pos and similar getters: stop importing mcrfpy per property read #331
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#331
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?
From the 2026-07-02 memory-model review. Internal fix, no API change.
Problem
UIDrawable::get_pos(src/UIDrawable.cpp:575-595) executes, per property read:PyImport_ImportModule("mcrfpy")PyObject_GetAttrString(module, "Vector")Py_BuildValue("(ff)")PyObject_CallObject(full Python-level constructor).posis one of the hottest properties in game scripts; this is an import + attr lookup + tuple alloc + type call where a direct allocation would do.Fix
All PyTypeObjects are
inlineC++17 definitions, so&mcrfpydef::PyVectorTypeis directly referenceable from anywhere (this is exactly why PyTypeCache was deleted). Replace the ceremony withtp_allocon the type + setdata = sf::Vector2f(x, y)-- same patternget_color_memberalready uses viaPyColor(...).pyObject().Scope
PyImport_ImportModuleoutside init paths).frame.pos); add totests/benchmarks/.Related: #255 (perf tracking), #326 (if proxies win that decision, this fast path is where the proxy would be constructed).