Python CEL 0.7.0 gives you a much bigger built-in toolbox, lets you call your own functions as methods, and can tell you what an expression uses before you run it — on top of a refreshed, more secure Rust core.
✨ What's new
An extended standard library — dozens of functions matching Google's cel-go, opt-in via cel.stdlib:
import cel
from cel.stdlib import add_stdlib_to_context
ctx = cel.Context()
add_stdlib_to_context(ctx)
cel.evaluate('"Hello World".lowerAscii()', ctx) # 'hello world'
cel.evaluate("math.greatest([3, 1, 2])", ctx) # 3
cel.evaluate("[1, 1, 2, 3].distinct()", ctx) # [1, 2, 3]
cel.evaluate('base64.encode(b"hi")', ctx) # 'aGk='Covers strings, math, sets, encoders and lists helpers (plus bool/dyn/type/min/max). The cel command-line tool enables them automatically.
Call custom functions as methods — a function you register works as both f(x) and x.f(y):
ctx = cel.Context()
ctx.add_function("shout", lambda s: s.upper() + "!")
cel.evaluate('"hi".shout()', ctx) # 'HI!'Inspect an expression before running it — see which variables and functions it references:
program = cel.compile("user.age >= min_age && size(roles) > 0")
program.variables() # ['min_age', 'roles', 'user']
program.functions() # ['_&&_', '_>=_', '_>_', 'size']Handy for validating that your context supplies everything an expression needs, or restricting which names an expression may touch.
⚡ Under the hood
- Upgraded to cel-rust 0.14 — faster and more spec-compliant.
- Upgraded to PyO3 0.29, which pulls in upstream security fixes.
- Clearer, more Pythonic error messages (e.g.
TypeError: Unsupported operation: string + int).
⚠️ Heads up — behaviour changes
These come from cel 0.14 and may affect existing expressions:
containsis now string-only. Use theinoperator for membership —2 in [1, 2, 3],"key" in myMap— or enable thelistsextension to get.contains()back for lists and maps.min/maxmoved into the opt-incel.stdlibcoreextension (they used to be always available).- Built-in functions take precedence over a custom function registered with the same name.
📦 Install / upgrade
pip install --upgrade common-expression-languageSee the CHANGELOG for the complete list of changes, and the docs for the new standard-library and introspection reference.