473,378 Members | 1,543 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 1375
[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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Brian Patterson | last post by:
I have noticed in the book of words that hasattr works by calling getattr and raising an exception if no such attribute exists. If I need the value in any case, am I better off using getattr...
7
by: Dennis Roberts | last post by:
I have a script to parse a dns querylog and generate some statistics. For a 750MB file a perl script using the same methods (splits) can parse the file in 3 minutes. My python script takes 25...
44
by: Carl | last post by:
"Nine Language Performance Round-up: Benchmarking Math & File I/O" http://www.osnews.com/story.php?news_id=5602 I think this is an unfair comparison! I wouldn't dream of developing a numerical...
5
by: sandy | last post by:
Hi All, I am a newbie to MySQL and Python. At the first place, I would like to know what are the general performance issues (if any) of using MySQL with Python. By performance, I wanted to...
1
by: Marc H. | last post by:
Hello, I recently converted one of my perl scripts to python. What the script does is simply search a lot of big mail files (~40MB) to retrieve specific emails. I simply converted the script...
3
by: David Jones | last post by:
Hi, I am trying to hunt down the difference in performance between some raw C++ code and calling the C++ code from Python. My goal is to use Python to control a bunch of number crunching code,...
3
by: adsheehan | last post by:
Hi all, Wondering if a GIL lock/unlock causes a re-schedule/contect swap when embedding Python in a multi-threaded C/C++ app on Unix ? If so, do I have any control or influence on this...
14
by: Bill | last post by:
I've written a small program that, in part, reads in a file and parses it. Sometimes, the file is gzipped. The code that I use to get the file object is like so: if filename.endswith(".gz"):...
1
by: spr | last post by:
Hi, I'm trying to learn Python and I'd appreciate any comments about my small snippets of code. I read an old anecdote about performance here: http://www.python.org/doc/essays/list2str/ ...
6
by: miller.paul.w | last post by:
Is there any place outside the actual C source for Python that has information about the performance of Python's built-in operations? For example, I'd *expect* list.append to be O(1), and I hope...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.