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
Metadata
Release files for python-cel 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_cel-0.1.1-cp39-abi3-manylinux_2_34_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.34+ x86-64 | Details for python_cel-0.1.1-cp39-abi3-manylinux_2_34_x86_64.whl |
Release files / python_cel-0.1.1-cp39-abi3-manylinux_2_34_x86_64.whl
| Download URL | python_cel-0.1.1-cp39-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.9 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f7ffaa78a0e6482b83a8d8545453b600d32cdffb3005284be11aa82c97c15dcc
|
|
BLAKE2b-256 checksum How to use checksums |
d3a79e965f256d58570ad433088a91d55f0e9bc657f26767511dfa9fcf2542fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.10
|
Security for python-cel 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.