[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

Ethan Furman report at bugs.python.org
Tue Jan 12 11:28:22 EST 2021


Ethan Furman <ethan at stoneleaf.us> added the comment:

If an optimization changes semantics it's not an optimization.

In  `if x: pass` how do we know `x` is falsely without calling `bool()` on it?

---

On a slightly different note, in the code:

    if a and b:
       ...

why is `bool(a)` called twice?

----------
nosy: +ethan.furman

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42899>
_______________________________________


More information about the Python-bugs-list mailing list