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
{{ message }}
Repository navigation
Match CPython CFG normalization and jump cleanup in late codegen passes #25
A large share of the remaining bytecode drift comes from control-flow graph normalization, jump threading, and
cleanup-tail layout differences. This affects multiple files, including Lib/test/test_buffer.py, Lib/test/ test_dis.py, Lib/test/test_math.py, Lib/test/test_tarfile.py, and Lib/dataclasses.py.
Evidence
Representative mismatches include:
POP_JUMP_IF_TRUE vs POP_JUMP_IF_FALSE polarity flips
FOR_ITER target drift
JUMP_FORWARD vs duplicated inline tail blocks
CPython NOP anchors vs RustPython LOAD_CONST None
shared exit blocks being duplicated or threaded differently from CPython
Top affected tracked files include:
Lib/test/test_buffer.py: 5131 diffs
Lib/test/test_dis.py: 3194 diffs
Lib/test/test_math.py: 2368 diffs
Lib/test/test_tarfile.py: 2149 diffs
Lib/dataclasses.py: 1577 diffs
Expected direction
Late CFG passes should be aligned with CPython’s codegen.c and flowgraph.c behavior, especially for:
conditional-chain normalization
jump threading
empty-block cleanup
exit duplication
synthetic NOP / no-location anchor handling
Likely implementation areas
crates/codegen/src/ir.rs
crates/codegen/src/compile.rs
Done when
Representative functions such as jumpy, dataclasses._asdict_inner, dataclasses._replace, tarfile
context-manager tests, and the larger test_buffer.py helpers converge to CPython bytecode structure instead
of only matching outcome.
Resolved for the scope described in this issue. The representative targets now match CPython bytecode with :\n\n- : 1 match, 0 differ, 0 errors\n- : 1 match, 0 differ, 0 errors\n- : 1 match, 0 differ, 0 errors\n- : 1 match, 0 differ, 0 errors\n- : 1 match, 0 differ, 0 errors\n\nThe full Lib comparison still has 55 differing files, but those are outside the representative #25 target set and are now tracked separately in #30.
Activity
youknowone commentedon Apr 30, 2026
RustPython#7721
youknowone commentedon May 19, 2026
Resolved for the scope described in this issue. The representative targets now match CPython bytecode with :\n\n- : 1 match, 0 differ, 0 errors\n- : 1 match, 0 differ, 0 errors\n- : 1 match, 0 differ, 0 errors\n- : 1 match, 0 differ, 0 errors\n- : 1 match, 0 differ, 0 errors\n\nThe full Lib comparison still has 55 differing files, but those are outside the representative #25 target set and are now tracked separately in #30.
youknowone commentedon May 19, 2026
Correction: the previous closing comment lost inline-code text due to shell quoting. The intended closure note is:
Resolved for the scope described in this issue. The representative targets now match CPython bytecode with
scripts/compare_bytecode.py:Lib/test/test_buffer.py: 1 match, 0 differ, 0 errorsLib/test/test_dis.py: 1 match, 0 differ, 0 errorsLib/test/test_math.py: 1 match, 0 differ, 0 errorsLib/test/test_tarfile.py: 1 match, 0 differ, 0 errorsLib/dataclasses.py: 1 match, 0 differ, 0 errorsThe full Lib comparison still has 55 differing files, but those are outside the representative #25 target set and are now tracked separately in #30.