[Python-ideas] [Python-Dev] yield * (Re: Missing operator.call)
steve at pearwood.info
Mon Feb 9 12:00:25 CET 2009
Marcin 'Qrczak' Kowalczyk wrote:
> On Sun, Feb 8, 2009 at 23:20, Steven D'Aprano <steve at pearwood.info> wrote:
>> And the cost is small:
>> [steve at ando ~]$ python -m timeit -s "seq = range(500)" "(3*x for x in seq if
>> x%2 == 1)"
>> 1000000 loops, best of 3: 0.611 usec per loop
> Because generators are lazy and you don't run it into completion.
We were talking about the cost of *making* the generator, not the cost
of running it to completion.
More information about the Python-ideas