SyntaxError on progress module
Steven D'Aprano
steve at pearwood.info
Wed May 27 21:39:47 EDT 2015
On Thu, 28 May 2015 06:03 am, Mark Lawrence wrote:
> You make the statement regarding Python3 "even while it is 10 to 20
> percent slower". Where is your evidence to support this statement?
Its well known that Python 3 is generally slower than Python 2. Cecil's
claim shouldn't be controversial, any more than "Python is generally about
10 to 100 times slower than C" should be controversial.
But for what it's worth:
[steve at ando ~]$ python2.7 -m timeit "i=1; L=sorted([30,20,50,10,40]);
L[i+1]"
1000000 loops, best of 3: 1.54 usec per loop
[steve at ando ~]$ python3.3 -m timeit "i=1; L=sorted([30,20,50,10,40]);
L[i+1]"
1000000 loops, best of 3: 1.62 usec per loop
which is an 8% slowdown.
On the other hand:
[steve at ando ~]$ python2.7 -m timeit "i='1'; L=sorted([30,20,50,10,40]);
L[int(i)+1]"
100000 loops, best of 3: 2.6 usec per loop
[steve at ando ~]$ python3.3 -m timeit "i='1'; L=sorted([30,20,50,10,40]);
L[int(i)+1]"
100000 loops, best of 3: 2.29 usec per loop
which is a 12% speed up. So the lesson is, micro-benchmarks are not a good
guide to whole-application benchmarks.
--
Steven
More information about the Python-list
mailing list