Author rhettinger
Recipients rhettinger, steven.daprano
Date 2019-06-05.05:24:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1559712244.32.0.839962107784.issue37158@roundup.psfhosted.org>
In-reply-to
Content
fmean() can be sped-up by converting count() from a function to a generator and by using enumerate() to do the counting.

-- Baseline ---
$ ./python.exe -m timeit -r11 -s 'from statistics import fmean' -s 'data=list(map(float, range(1000)))' 'fmean(iter(data))'
2000 loops, best of 11: 108 usec per loop

-- Patched -- 
$ ./python.exe -m timeit -r11 -s 'from statistics import fmean' -s 'data=list(map(float, range(1000)))' 'fmean(iter(data))'
5000 loops, best of 11: 73.1 usec per loop
History
Date User Action Args
2019-06-05 05:24:04rhettingersetrecipients: + rhettinger, steven.daprano
2019-06-05 05:24:04rhettingersetmessageid: <1559712244.32.0.839962107784.issue37158@roundup.psfhosted.org>
2019-06-05 05:24:04rhettingerlinkissue37158 messages
2019-06-05 05:24:04rhettingercreate