Skip to content

Split partial evaluation into smaller phase-owned modules #143

Description

@lbliii

Context

partial_eval.py is one of the highest-risk files in the project: it owns compile-time evaluation, constant folding, dead-code elimination, loop unrolling, call inlining, and flattening. It is large enough that unrelated changes are likely to collide and tests are similarly concentrated.

Evidence

  • src/kida/compiler/partial_eval.py is 2,307 lines.
  • PartialEvaluator spans about 1,671 lines.
  • _transform_expr alone is about 298 lines.
  • tests/test_partial_eval.py is 3,527 lines.

Proposed Scope

  • Split the implementation along behavior boundaries, such as expression evaluation, control-flow transforms, call/def inlining, loop unrolling, and flattening.
  • Preserve the public partial_evaluate_template() entrypoint.
  • Split or regroup tests around the same behavior boundaries.
  • Include benchmark/no-benchmark rationale because this is compiler hot-path-adjacent.

Done When

  • Partial-eval changes can be reviewed in smaller files with clear ownership.
  • Existing partial-eval tests still pass.
  • Compiler benchmark expectations are unchanged or documented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions