[Python-ideas] Break the dominance of boolean values in boolean context
greg.ewing at canterbury.ac.nz
Wed Sep 14 01:35:08 CEST 2011
Guido van Rossum wrote:
> It would mean that the compiler no longer has the
> option to translate "if not" into a reversal of the control flow;
This only seems to happen when the expression is used
directly as the subject of an if-test. For the use cases
I had in mind when I wrote PEP 335, this wouldn't
happen -- you're building a parse tree in order to
perform some other processing on it, not to immediately
use it in an if-branch.
So I think it would be fine for the compiler to reserve
the right to apply the laws of boolean algebra to
simplify an expression that appears in a boolean context.
More information about the Python-ideas