Consume an iterable

Jan Kaliszewski zuo at chopin.edu.pl
Sun Jan 24 11:49:32 EST 2010


> Don't the results look suspicious to you? Try measuring with
>
> iterator = iter([])

You are obviously right, my brain doesn't work well today :-(

But the corret results even more distinctly support my thesis -- that for  
n=None using n=sys.maxint (consume3) is noticeably faster than 0-maxlen  
deque (consume1 and consume2):

consume0
     10: 4.06217813492
    100: 8.45529103279
   1000: 53.237226963
   None: 54.0063519478

consume1
     10: 2.59927105904
    100: 3.47109603882
   1000: 12.7196500301
   None: 26.0995740891

consume2
     10: 2.36225390434
    100: 3.22979712486
   1000: 12.5794699192
   None: 28.5096430779

consume3
     10: 2.39173388481
    100: 3.43043398857
   1000: 14.3361399174
   None: 14.8560190201


Regards,
*j

-- 
Jan Kaliszewski (zuo) <zuo at chopin.edu.pl>



More information about the Python-list mailing list