Re:Python 3.11 vs 3.10 performance
by int_19h on Wednesday July 06, 2022 @09:25PM
(#32008944)
Not really; where would you put it inside the []?
[ Parent
| on HN ]
Re:Python 3.11 vs 3.10 performance
by dragonwriter on Wednesday July 06, 2022 @09:33PM
(#32008981)
In the example from the end of the earlier post:
y
for x in xs
if (y:=x.ComputeSomething()).IsFoo and y.IsBarI suppose that works, although readability is not great, to put it mildly.
Re:Python 3.11 vs 3.10 performance
by texaslonghorn5 on Wednesday July 06, 2022 @11:21PM
(#32009580)
Much better would be
[(y:=x.ComputeSomething()) for x in xs if y.IsFoo and y.IsBar]
That doesn't work, because that first subexpression is evaluated last, after "if".
Re:Python 3.11 vs 3.10 performance
by ChadNauseam on Wednesday July 06, 2022 @11:37PM
(#32009649)
For another example of how to use the walrus operator, I use it multiple times in the code I linked a few comments up