Skip to content

Investigate LOAD_CONST vs LOAD_SMALL_INT / Constant Folding Drift #22

@youknowone

Description

@youknowone

Background:
There are repeated differences where LOAD_CONST and LOAD_SMALL_INT/numeric literals
diverge, often accompanied by subsequent stack changes. This likely stems from constant
folding or literal emission policy.

Task:

  • Reconcile constant-literal emission rules in compiler constant folding/codegen phases.
  • Normalize behavior where CPython would emit constant object vs inline small-int
    opcodes.
  • Audit for cases where tuple/list/dict literal assembly diverges (LOAD_CONST shapes,
    tuple packing, slice/build helpers).

Acceptance criteria:

  • Large LOAD_CONST-related mismatches reduced, especially in numeric-heavy code paths.
  • Bytecode shape remains semantically equivalent for float/int/string constant
    expressions.

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