# partial_eval_constants

URL: /kida/api/compiler/partial_eval_constants/
Section: compiler
Description: 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
public ``partial_evaluate()`` or ``eliminate_dead_code()`` entrypoints.

---

> For a complete page index, fetch /kida/llms.txt.

Open LLM text
(/kida/api/compiler/partial_eval_constants/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fpartial_eval_constants%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fpartial_eval_constants%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fpartial_eval_constants%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fcompiler%2Fpartial_eval_constants%2Findex.txt)

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
public`partial_evaluate()` or `eliminate_dead_code()`entrypoints.

2Functions

## 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`
