Python bindings for the cel-rust crate
Project description
Python CEL
Python CEL are Python bindings for the Common Expression Language (CEL) rust implementation found here. CEL is a language designed to allow non-sandboxed evaluation of expressions and scripts.
Features
- Written in Rust: The underlying library and bindings are written in Rust, which makes it fast and memory-efficient.
- Safe: The Rust implementation is memory-safe and thread-safe.
- Extensible: The library is designed to be easily extensible with custom functions and variables.
Quick Start
Installation
pip install python-cel
Basic Usage
from cel import Context, Program, evaluate_expression
# Quickly evaluate an expression
result = evaluate_expression("1 + 2")
print(result) # 3
result = evaluate_expression("x + y", variables={"x": 1, "y": 3})
print(result) # 4
result = evaluate_expression("add_nums(1, 2)", functions={"add_nums": lambda x, y: x + y})
print(result) # 3
# Manually create a context and program
context = Context()
context.add_variables({"x": 1, "y": 2})
context.add_functions({"add_nums": lambda x, y: x + y})
# OR
context = Context(
variables={"x": 1, "y": 2},
functions={"add_nums": lambda x, y: x + y}
)
program = Program("add_nums(x, y)")
result = program.evaluate(context)
print(result) # 3
License
This project is licensed under MIT License.
Support & Feedback
If you encounter any issues or have feedback, please open an issue. We'd love to hear from you!
Made with ❤️ by Emergent Methods
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_cel-0.1.1-cp39-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: python_cel-0.1.1-cp39-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7ffaa78a0e6482b83a8d8545453b600d32cdffb3005284be11aa82c97c15dcc
|
|
| MD5 |
a216d2f5e8f96ad76be573509be67232
|
|
| BLAKE2b-256 |
d3a79e965f256d58570ad433088a91d55f0e9bc657f26767511dfa9fcf2542fb
|