
On 2018-02-28 02:46, Matt Arcidy wrote:
From readability, the examples put forth have been to explain the advantage, with which I agree. However, i do not believe this scales well.
[(foo(x,y) as g)*(bar(y) as i) + g*foo(x,a) +baz(g,i) for x... for y...]
That's 3 functions, 2 iterators, 3 calls saved ('a' is some constant just to trigger a new call on foo). I'm not trying to show ugly statements can be constructed, but show how quickly in _n iterators and _m functions readability declines.
You could put it on multiple lines
[ (g * i) + g * foo(x, a) + baz(g, i) for x in X for y in Y for g in [foo(x,y)] for i in [bar(y)] ]
and then notice a common factor! :)
[ g * (i + foo(x, a) + baz(g, i)) for x in X for y in Y for g in [foo(x,y)] for i in [bar(y)] ]