Summary
Many remaining diffs are no longer about control-flow or constants, but about the exact local-variable opcode
forms RustPython chooses.
Evidence
Recurring mismatches include:
LOAD_FAST vs LOAD_FAST_BORROW
LOAD_FAST_LOAD_FAST vs LOAD_FAST_BORROW_LOAD_FAST_BORROW
STORE_FAST vs STORE_FAST_STORE_FAST
STORE_FAST_LOAD_FAST where CPython keeps separate instructions
This pattern appears across:
Lib/test/test_buffer.py
Lib/test/test_math.py
Lib/test/test_tarfile.py
Lib/dataclasses.py
Lib/test/test_dis.py
Expected direction
Borrow opcode and fused local opcode selection should follow CPython’s optimizer decisions, not a RustPython-
specific heuristic. This should be driven by the same structural conditions CPython uses.
Likely implementation areas
crates/codegen/src/ir.rs
- local-op fusion and borrow/deopt logic after CFG shaping
Done when
Representative functions in the files above stop drifting on borrow/fused local opcodes and match CPython’s
chosen opcode forms.
Summary
Many remaining diffs are no longer about control-flow or constants, but about the exact local-variable opcode
forms RustPython chooses.
Evidence
Recurring mismatches include:
LOAD_FASTvsLOAD_FAST_BORROWLOAD_FAST_LOAD_FASTvsLOAD_FAST_BORROW_LOAD_FAST_BORROWSTORE_FASTvsSTORE_FAST_STORE_FASTSTORE_FAST_LOAD_FASTwhere CPython keeps separate instructionsThis pattern appears across:
Lib/test/test_buffer.pyLib/test/test_math.pyLib/test/test_tarfile.pyLib/dataclasses.pyLib/test/test_dis.pyExpected direction
Borrow opcode and fused local opcode selection should follow CPython’s optimizer decisions, not a RustPython-
specific heuristic. This should be driven by the same structural conditions CPython uses.
Likely implementation areas
crates/codegen/src/ir.rsDone when
Representative functions in the files above stop drifting on borrow/fused local opcodes and match CPython’s
chosen opcode forms.