Author stestagg
Recipients Mark.Shannon, Mohamed_Atef, gregory.p.smith, pablogsal, serhiy.storchaka, stestagg
Date 2021-01-12.11:39:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1610451567.64.0.514419364033.issue42899@roundup.psfhosted.org>
In-reply-to
Content
To be super pedantic, as per my understanding of:

"6.11 ... The expression x and y first evaluates x; if x is false, its value is returned; otherwise, y is evaluated and the resulting value is returned."

The only corner that was previously cut is that in this statement:

if a and b:
    ...


The evalution should be roughly equivalent to:

bool(a) if bool(a) else bool(b) # <- where bool(b) is never called

instead it's more like:

_x if _x := bool(a) else bool(b) # <- where bool(b) is never called

so, the runtime is eliding a repeated call to bool(a).

This obviously causes problems if bool(a) has per-call side-effects, but this seems to me like a reasonable corner to cut.

Totally eliding the if clause feels to me (subjectively) like a much more risky proposition, and perhaps one that should be documented if kept in?
History
Date User Action Args
2021-01-12 11:39:27stestaggsetrecipients: + stestagg, gregory.p.smith, Mark.Shannon, serhiy.storchaka, Mohamed_Atef, pablogsal
2021-01-12 11:39:27stestaggsetmessageid: <1610451567.64.0.514419364033.issue42899@roundup.psfhosted.org>
2021-01-12 11:39:27stestagglinkissue42899 messages
2021-01-12 11:39:27stestaggcreate