-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lang] Add option short_circuit_operators for short-circuiting boolean ops #3632
Conversation
✔️ Deploy Preview for jovial-fermat-aa59dc canceled. 🔨 Explore the source changes: ecc5e92 🔍 Inspect the deploy log: https://app.netlify.com/sites/jovial-fermat-aa59dc/deploys/61a2d7bc510b850007dd6267 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Only a tiny thing to notice below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, this method always needs len(node.values) - 1
times of comparison when executing. When the program meets a false
in and
operation, the comparison after it is not necessary. This can be achieved by generating nested ifs.
I agree. Your comment reminds me that Python AST treats @re-xyr FYI https://docs.python.org/3/library/ast.html#ast.BoolOp. |
nice catch - will fix this. Not sure why Python doesn't just make boolean operators right-associative though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the expected behavior of bool expressions is to be determined, other parts look good to me. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks!
short_circuit_operators
for short-circuiting boolean ops
short_circuit_operators
for short-circuiting boolean ops
Related issue = Fixes #3572
cc @strongoier