Author Mark.Shannon
Recipients Mark.Shannon, Mohamed_Atef, gregory.p.smith, gvanrossum, pablogsal, serhiy.storchaka, stestagg
Date 2021-01-12.16:02:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610467335.76.0.512387606053.issue42899@roundup.psfhosted.org>
In-reply-to
Content
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`.
History
Date User Action Args
2021-01-12 16:02:15Mark.Shannonsetrecipients: + Mark.Shannon, gvanrossum, gregory.p.smith, serhiy.storchaka, Mohamed_Atef, pablogsal, stestagg
2021-01-12 16:02:15Mark.Shannonsetmessageid: <1610467335.76.0.512387606053.issue42899@roundup.psfhosted.org>
2021-01-12 16:02:15Mark.Shannonlinkissue42899 messages
2021-01-12 16:02:15Mark.Shannoncreate