[Python-ideas] [Python-Dev] yield * (Re: Missing operator.call)
Antoine Pitrou
solipsis at pitrou.net
Sun Feb 8 19:54:25 CET 2009
Steven D'Aprano <steve at ...> writes:
> The advantage is even more obvious when married with a generator expression:
>
> yield from (3*x for x in seq if x%2 == 1)
>
> instead of:
>
> for x in seq:
> if x%2 == 1:
> yield 3*x
But the former will be slower than the latter, because it constructs an
intermediate generator only to yield it element by element.
Regards
Antoine.
More information about the Python-ideas
mailing list