DAGDA SEARCH | Back to results | Support

Message 384958 - Python tracker

Source: https://bugs.python.org/msg384958

homepage

Message384958 ➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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
Supported by The Python Software Foundation,
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements