[Python-ideas] [Python-Dev] yield * (Re: Missing operator.call)

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Mon Feb 9 00:15:00 CET 2009


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.

-- 
Marcin Kowalczyk
qrczak at knm.org.pl
http://qrnik.knm.org.pl/~qrczak/



More information about the Python-ideas mailing list