Mark Shannon <[email protected]> added the comment:
It's clearer if you rewrite
if a and b:
...
as
tmp = a and b
if tmp:
...
if a is falsey then bool(a) gets called in `tmp = a and b` and `a` is assigned
to `tmp`. Then in `if tmp`, bool(a) is called again.
I agree with you about it not being an optimization if it changes the
semantics. But only within agreed semantics.
Optimizations are allow to make fewer calls to __hash__() in a dictionary, or
change race conditions, because those are outside of the language specification.
----------
_______________________________________
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