On 13/01/2021 12:18 pm, Rob Cliffe wrote:
On 12/01/2021 15:53, Mark Shannon wrote:
In master we convert `if x: pass` to `pass` which is equivalent, unless bool(x) has side effects the first time it is called. This is a recent change.
Can you please confirm that this optimisation ONLY applies to bare names, i.e. NOT
if x(): pass if x.y: pass if x+y: pass
The optimization doesn't apply to the expression, but the test. The optimizer (might) transform
if x+y: pass
But the expression is still evaluated. Sorry for the confusion, I should have been clearer in my example. It is the call to `bool()` that *might* be eliminated.
Thanks Rob Cliffe