Skip to content

Align constant-table and nested code-object emission order in large modules #28

@youknowone

Description

@youknowone

Summary

Some large remaining diffs are dominated by module-level constant layout and nested code-object ordering, not
only by local CFG issues.

Evidence

The clearest cases are:

  • Lib/test/test_ast/snippets.py: 1 code object, 4216 instruction diffs
  • Lib/test/test_dis.py: module-level drift plus smaller function-level drift

Representative mismatches include:

  • CPython loading a large constant blob or nested code object from co_consts
  • RustPython loading a different constant earlier, or emitting nested code objects in a different order
  • large EXTENDED_ARG / constant-index layout divergence caused by different constant ordering

Expected direction

RustPython should match CPython’s ordering for:

  • nested code object insertion
  • large constant materialization
  • constant-table population where it affects emitted bytecode

Likely implementation areas

  • crates/codegen/src/compile.rs
  • code-object construction / constant collection order

Done when

test_ast/snippets.py and the module-level part of test_dis.py stop diverging as a single giant constant-
layout mismatch and instead match CPython’s constant ordering and nested code-object structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions