cel-python icon indicating copy to clipboard operation
cel-python copied to clipboard

Evaluate a condition branch only if needed

Open sewi-cpan opened this issue 2 years ago • 2 comments

The CEL language definition suggests:

To get traditional left-to-right short-circuiting evaluation of logical operators, as in C or other languages (also called "McCarthy Evaluation"), the expression e1 && e2 can be rewritten e1 ? e2 : false. Similarly, e1 || e2 can be rewritten e1 ? true : e2.

cel-python used to evaluate the full tree before deciding if a branch will be used or not. This PR only evaluates a branch if selected by the condition.

Fixes https://github.com/cloud-custodian/cel-python/issues/50

sewi-cpan avatar Dec 06 '23 14:12 sewi-cpan

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: kapilt / name: Kapil Thangavelu (9c75fd30329fbd9c763d7d129cf285f503772c73)
  • :white_check_mark: login: sewi-cpan / name: Sebastian Willing (1d6ce96137fc49fcf18edfceac667517dd833b68)

thanks for the pr, lgtm although a test would be appreciated, would also appreciate a look by @slott56

kapilt avatar Dec 22 '23 16:12 kapilt

See https://github.com/cloud-custodian/cel-python/pull/63 which fixes this problem.

slott56 avatar May 25 '24 01:05 slott56