470,841 Members | 1,089 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,841 developers. It's quick & easy.

Performance of Python 2.3 and 2.4

Hi!

I was just wondering...

Python 2.3.5 (#2, Mar 6 2006, 10:12:24)
[GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import timeit
a = timeit.Timer('2**100000000')
b = timeit.Timer('112233445566778899 * 112233445566778899')
a.timeit(1) 5.3986599445343018 b.timeit() 0.59309601783752441

Python 2.4.2 (#2, Nov 20 2005, 17:04:48)
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information. import timeit
a = timeit.Timer('2**100000000')
b = timeit.Timer('112233445566778899 * 112233445566778899')
a.timeit(1) 13.129707813262939 b.timeit()

0.72854804992675781

Why long numbers operations are slower in 2.4?

mk
--
. o . >> http://joker.linuxstuff.pl <<
. . o It's easier to get forgiveness for being wrong
o o o than forgiveness for being right.
Apr 22 '06 #1
2 1249
[Michal Kwiatkowski]
I was just wondering...

Python 2.3.5 (#2, Mar 6 2006, 10:12:24)
[GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import timeit
a = timeit.Timer('2**100000000')
b = timeit.Timer('112233445566778899 * 112233445566778899')
a.timeit(1) 5.3986599445343018 b.timeit() 0.59309601783752441

Python 2.4.2 (#2, Nov 20 2005, 17:04:48)
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information. import timeit
a = timeit.Timer('2**100000000')
b = timeit.Timer('112233445566778899 * 112233445566778899')
a.timeit(1) 13.129707813262939 b.timeit()

0.72854804992675781

Why long numbers operations are slower in 2.4?


In general, they're not. Here on Windows, with those specific examples:

"""
$ type ls.py
import timeit
a = timeit.Timer('2**100000000')
b = timeit.Timer('112233445566778899 * 112233445566778899')
print a.timeit(1)
print b.timeit()

$ \python23\python ls.py
6.96490123499
0.266523717213

$ \python24\python ls.py
6.81509407621
0.204446820019
"""

So 2.4 is faster on those specific examples here. Some of that's
probably due to code changes, and the rest to that the released
Windows 2.3.5 and 2.4.3 were compiled with different versions of MS's
C compiler, and VC 7.1 happened to do better optimization of the
relevant C code than VC 6.0.

I note that your Pythons were compiled with different (pre)releases of
gcc, so if you want to pursue this the first thing to do is compile
both Pythons with the same gcc. The effectiveness of the platform C's
optimization matters a lot here.
Apr 22 '06 #2
Em Dom, 2006-04-23 √*s 00:20 +0200, Michal Kwiatkowski escreveu:
Hi!

I was just wondering...


Probably there is another factor involved:

$ python2.3
Python 2.3.5 (#2, Mar 6 2006, 10:12:24)
[GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import timeit
timeit.Timer('2**100000000').timeit(1) 4.6463479995727539 timeit.Timer('112233445566778899 * 112233445566778899').timeit() 0.44853687286376953
$ python2.4
Python 2.4.3 (#2, Mar 30 2006, 21:52:26)
[GCC 4.0.3 (Debian 4.0.3-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information. import timeit
timeit.Timer('2**100000000').timeit(1) 4.9987671375274658 timeit.Timer('112233445566778899 * 112233445566778899').timeit()

0.36968302726745605

--
Felipe.

Apr 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by Brian Patterson | last post: by
7 posts views Thread by Dennis Roberts | last post: by
5 posts views Thread by sandy | last post: by
3 posts views Thread by David Jones | last post: by
3 posts views Thread by adsheehan | last post: by
14 posts views Thread by Bill | last post: by
1 post views Thread by spr | last post: by
6 posts views Thread by miller.paul.w | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.