Hi Rob, 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. NOTif 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 to x+y 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. Cheers, Mark.
Thanks Rob Cliffe
_______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/YZMA3ABVUKJ3PDFO4BS56QRSL4YCC3DJ/ Code of Conduct: http://python.org/psf/codeofconduct/