Why generators take long time?
Arshpreet Singh
arsh840 at gmail.com
Tue Jan 19 14:35:18 EST 2016
On Tuesday, 19 January 2016 15:42:16 UTC+5:30, Steven D'Aprano wrote:
> [steve at ando ~]$ python -m timeit -s "from collections import deque"
> -s "it = iter([i for i in xrange(1000)])" "deque(it, maxlen=0)"
> 1000000 loops, best of 3: 0.913 usec per loop
>
>
> [steve at ando ~]$ python -m timeit -s "from collections import deque"
> -s "it = (i for i in xrange(1000))" "deque(it, maxlen=0)"
> 1000000 loops, best of 3: 0.965 usec per loop
Thanks Steven, it was really helpful answer.
More information about the Python-list
mailing list