Message384921
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? |
|
Date |
User |
Action |
Args |
2021-01-12 11:39:27 | stestagg | set | recipients:
+ stestagg, gregory.p.smith, Mark.Shannon, serhiy.storchaka, Mohamed_Atef, pablogsal |
2021-01-12 11:39:27 | stestagg | set | messageid: <1610451567.64.0.514419364033.issue42899@roundup.psfhosted.org> |
2021-01-12 11:39:27 | stestagg | link | issue42899 messages |
2021-01-12 11:39:27 | stestagg | create | |
|