Mark Shannon <[email protected]> added the comment:
They aren't quite the same. If `a` is falsey, and bool(a) has a side-effect,
then that side-effect should occur twice in:
if a and b:
...
but only once in
if a:
if b:
...
It gets more interesting (silly), if `a.__bool__()` alternated between True and
False.
If we say that such behavior is illegal, and can be ignored by the optimizer,
then 3.10 is correct (as it stands).
My example was wrong though, as you've pointed out.
`if x: pass` it transformed to `x`. It is the test that is eliminated, not the
evaluation of `x`.
----------
priority: release blocker -> normal
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42899>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com