Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compiled bytecode #307

Merged
merged 6 commits into from
Feb 10, 2025
Merged

feat: compiled bytecode #307

merged 6 commits into from
Feb 10, 2025

Conversation

stefan-gorules
Copy link
Contributor

@stefan-gorules stefan-gorules commented Feb 6, 2025

Expression Engine Optimization

This PR introduces compiled bytecode capabilities and significant performance optimizations to the expression engine. It adds support for pre-compiling expressions and reusing them across multiple evaluations, along with bytecode optimizations for common operations.

Features

  • ✨ Added support for compiled expressions that can be reused across evaluations
  • 🚀 Implemented Fast Path for member access operations
  • 🔧 Optimized bytecode representation with specialized opcodes
  • 🏗️ Added new Expression type with Standard and Unary variants
  • 📦 Extended Python bindings to support compiled expressions

Example Usage

# Compile once, evaluate multiple times
expr = zen.compile_expression("50 * tax.percentage / 100")

# Single evaluation
result = expr.evaluate({"tax": {"percentage": 10}})

# Batch evaluation
results = expr.evaluate_many([
    {"tax": {"percentage": 10}},
    {"tax": {"percentage": 20}},
    {"tax": {"percentage": 15}}
])

Performance Impact

  • Eliminates repeated parsing and compilation overhead
  • Optimizes common member access patterns
  • Reduces memory allocations during evaluation
  • Enables efficient batch processing of expressions

@stefan-gorules stefan-gorules merged commit ae40aff into master Feb 10, 2025
43 checks passed
@stefan-gorules stefan-gorules deleted the feat/compiled-bytecode branch February 10, 2025 09: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.

2 participants