Skip to content

Upgrade/cel 0.12.0#28

Merged
hardbyte merged 6 commits into
mainfrom
upgrade/cel-0.12.0
Feb 7, 2026
Merged

Upgrade/cel 0.12.0#28
hardbyte merged 6 commits into
mainfrom
upgrade/cel-0.12.0

Conversation

@hardbyte

@hardbyte hardbyte commented Feb 7, 2026

Copy link
Copy Markdown
Owner
  • Bump cel crate to 0.12.0 and enable bytes feature to preserve Python bytes support.
  • Add OptionalValue Python wrapper to properly surface CEL optional values (preserving optional.none() vs optional.of(null)).
  • Update docs, stubs, and tests to reflect new API and upstream behavior changes.
  • Refactor shared environment setup between evaluate and Program.execute.

Key Changes

  • Cargo.toml, Cargo.lock: upgrade cel to 0.12.0, add bytes feature.
  • src/lib.rs: OptionalValue wrapper, conversion logic, and shared environment builder.
  • python/cel/cel.pyi: add OptionalValue and compile/Program stubs.
  • Docs: avoid shadowing Python compile, add OptionalValue docs.
  • Tests: new optional wrapper tests; update upstream‑improvements expectations; relax perf thresholds slightly.

Behavior Notes

  • cel.evaluate("optional.of(42)") now returns cel.OptionalValue instead of a debug string.

  • Optional semantics preserved (optional.none() ≠ optional.of(null)).

  • compile()+execute() is ~6–8x faster for most expressions because it removes parse/compile from the hot path.

  • The list_size case barely improves because conversion dominates; the compile step is a smaller portion of the cost there.

  • Break‑even is very low (3–20 executions), so compile is worth it for any repeated evaluation.

m24130 and others added 6 commits December 4, 2025 07:56
Add ability to compile CEL expressions once and execute them multiple times
with different contexts. This provides ~12x speedup over evaluate() when
reusing the same expression.

New API:
- compile(expression) -> Program
- Program.execute(context) -> result

Example:
    program = compile('x + y')
    program.execute({'x': 1, 'y': 2})  # 3
    program.execute({'x': 10, 'y': 20})  # 30
Add examples demonstrating compile() and Program.execute() usage to README, quick-start guide, and Python API reference. Show performance pattern of compiling once and executing multiple times with different contexts.
@hardbyte hardbyte merged commit b8315f4 into main Feb 7, 2026
16 checks passed
@hardbyte hardbyte deleted the upgrade/cel-0.12.0 branch February 7, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant