Module

compiler.partial_eval_constants

Constant-expression primitives shared by partial-evaluation phases.

This module owns the literal-only evaluator used by dead-code elimination and the sentinel/error policy used by the static-context evaluator. Keeping these primitives separate makes the phase boundary explicit without changing the publicpartial_evaluate() or eliminate_dead_code()entrypoints.

Functions

compare_op 3 bool
Evaluate a comparison operator.
def compare_op(op: str, left: Any, right: Any) -> bool
Parameters
Name Type Description
op str
left Any
right Any
Returns
bool
try_eval_const_only 1 Any
Evaluate an expression using only literals and constant operators. Name, attri…
def try_eval_const_only(expr: Expr) -> Any

Evaluate an expression using only literals and constant operators.

Name, attribute, and item lookups intentionally remain unresolved because they require a static context. Dead-code elimination uses this narrower evaluator even when no static context is configured.

Parameters
Name Type Description
expr Expr
Returns
Any