On Fri, Jan 15, 2021 at 10:13 PM Rob Cliffe via Python-Dev <python-dev@python.org> wrote: > > > > On 12/01/2021 15:53, Mark Shannon wrote: > > Hi everyone, > > > > > > > > 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. > > > Suppose x is not a currently valid variable name at runtime. Will the > NameError still be "optimised" away?
No, it won't. The expression still gets fully evaluated. The ONLY part that gets optimized away is the check "is this thing true?". ChrisA _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/KQ2QH3VB5Q6LYCBE4SUWZKRMML54TOXS/ Code of Conduct: http://python.org/psf/codeofconduct/