You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
py/settrace: Add bytecode persistence of local variable names.
This commit completes the local variable name preservation feature by
persisting them in bytecode and updating all documentation
to reflect the complete implementation.
Enabled with #define MICROPY_PY_SYS_SETTRACE_LOCALNAMES_PERSIST (1)
- py/emitbc.c: Extended bytecode generation to include local names in source info
- py/persistentcode.c: Added save/load functions for .mpy local names support
- py/persistentcode.h: Function declarations for Phase 2 functionality
- Format detection via source info section size without bytecode version bump
Documentation Updates:
- docs/library/sys.rst: Enhanced user documentation with examples and features
- docs/develop/sys_settrace_localnames.rst: Added bytecode implementation details,
updated memory usage documentation, added compatibility matrix
Testing:
- tests/basics/sys_settrace_localnames_persist.py: bytecode persistence tests
- ports/unix/variants/standard/mpconfigvariant.h: Enabled feature for testing
Configuration:
- py/mpconfig.h: Updated dependencies documentation
Key Features:
- Backward/forward compatibility maintained across all MicroPython versions
- .mpy files can now preserve local variable names when compiled with feature enabled
- Graceful degradation when feature disabled or .mpy lacks local names
Memory Overhead:
- .mpy files: ~1-5 bytes + (num_locals * ~10 bytes) per function when enabled
- Runtime: Same as locals stored in ram when loading local names from .mpy files
Signed-off-by: Andrew Leech <[email protected]>
0 commit comments