Skip to content

feat: add compile() function and Program class for pre-compilation#26

Closed
m24130 wants to merge 2 commits into
hardbyte:mainfrom
m24130:feature/compile-api
Closed

feat: add compile() function and Program class for pre-compilation#26
m24130 wants to merge 2 commits into
hardbyte:mainfrom
m24130:feature/compile-api

Conversation

@m24130

@m24130 m24130 commented Dec 4, 2025

Copy link
Copy Markdown

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 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
@hardbyte

hardbyte commented Dec 5, 2025

Copy link
Copy Markdown
Owner

Awesome! Let's include tests and docs

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.
@m24130

m24130 commented Dec 5, 2025

Copy link
Copy Markdown
Author

Here it is

@hardbyte

hardbyte commented Feb 7, 2026

Copy link
Copy Markdown
Owner

Thanks so much - merged as part of #28

@hardbyte hardbyte closed this Feb 7, 2026
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.

2 participants