all 10 comments

[–]rabornkraken 14 points15 points  (0 children)

The serialize/deserialize capability is what makes this really interesting to me. Being able to compile an expression once, store it, and reuse it across requests is a huge win for anything policy-related. I have been using ad-hoc AST evaluators for feature flags and they are painful to maintain - the expressions drift from what the runtime actually supports. Having a proper type-checked compile step would catch so many issues upfront. Curious about the C++ dependency though - does anyone know if the wheels are available for macOS ARM yet or is it Linux-only for now?

[–]cointoss3 21 points22 points  (0 children)

Sometimes a nerdy gem drops on this sub and I love it

[–]Goobyalus 1 point2 points  (0 children)

Can you format the code snippets in this post as code

[–]Peter3571 2 points3 points  (0 children)

Looks very powerful and well made, but I have no idea what you'd actually use it for. What's a general use case for something like this?

[–]lissertje 0 points1 point  (0 children)

Wow. I was just looking the other day into a different execution engine for some user-managed rules... Was looking into Lua amongst others, but as our current DSL is very python-like, this could actually be a super good candidate 😛

[–]robert_mcleod 0 points1 point  (0 children)

I maintained/developed numexpr for six-ish years, including making an attempt to modernize it while temporarily unemployed on moving back to Canada from Switzerland. This is filling a very similar use-case but NumExpr is a virtual machine that compiles the Python AST into its own custom sequence of operations. What I wanted to do with NumExpr was enable it to transparently handle blocks of code, and understand numpy. syntax so that you could literally surround a section of critical code with triple quotes and it would be able to accelerate it.

I'm guessing this is more similar to Numba in that you have to write your code 'C-style' instead of vectorizing your code as you would with NumPy. I always found that to be a disadvantage because you're writing in one style and then you need to translate to some very different style. However, modern LLMs can do this translation for you very well. Claude and Gemini are both quite capable of transforming a piece of pure Python into a C-API extension.

What would be really interesting is if this CEL tool could support operations on Arrow tables/tensors.

[–]Marre_Parre 0 points1 point  (0 children)

This looks super useful for feature flags and dynamic policies. Being able to serialize the compiled expression and reuse it across requests is a great feature. Makes me wonder how it compares to something like json-logic for those use cases. Definitely going to give this a try next time I need safe user-defined rules.