473,396 Members | 2,111 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,396 software developers and data experts.

How to make python run faster

I read this article on http://kortis.to/radix/python_ext/

And I decided to try if it's true.

I write the program in 4 ways:

1. Pure C
2. Python using C extension
3. Python using psycho
4. Pure Python

And then I used timeit to test the speed of these 4. Unsurprisingly,
the time they cost were:

4 3 2 1

But I did noticed that 2 is a least 3 times slower than 1, not as fast
as the article stated.

That's quite weird and I thought maybe it's because I am using
Windows. I did the same test on Linux and I found 2 only uses 1.5
times of time of 1.

But, it is still not as fast as 1.
Jun 27 '08 #1
2 2710
On Apr 14, 8:48 am, Ò»Ê×Ê« <newpt...@gmail.comwrote:
But, it is still not as fast as 1.

So if speed is the #1 design goal, use pure C. If not, develop in
pure Python and, if the application is too slow, profile the code and
look for bottlenecks that can be optimized. There's a good chance
that they can be resolved algorithmically, not by simply dropping down
to C.
Jun 27 '08 #2
On 14 ¦¡¦Ð¦Ñ, 16:48, Ò»Ê×Ê« <newpt...@gmail.comwrote:
I read this article onhttp://kortis.to/radix/python_ext/

And I decided to try if it's true.

I write the program in 4 ways:

1. Pure C
2. Python using C extension
3. Python using psycho
4. Pure Python

And then I used timeit to test the speed of these 4. Unsurprisingly,
the time they cost were:

4 3 2 1

But I did noticed that 2 is a least 3 times slower than 1, not as fast
as the article stated.

That's quite weird and I thought maybe it's because I am using
Windows. I did the same test on Linux and I found 2 only uses 1.5
times of time of 1.

But, it is still not as fast as 1.
I have experimented too with this scenario. My conclusion is that it
aint worth it to mess with C. Program only in Python and when the time
comes that you want to speed up something, just use Psyco on this. And
that will be more than enough.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
38
by: kbass | last post by:
In different articles that I have read, persons have constantly eluded to the productivity gains of Python. One person stated that Python's productivity gain was 5 to 10 times over Java in some in...
36
by: Armin Rigo | last post by:
Hi! This is a rant against the optimization trend of the Python interpreter. Sorting a list of 100000 integers in random order takes: * 0.75 seconds in Python 2.1 * 0.51 seconds in Python...
15
by: Duncan Lissett | last post by:
I'd appreciate any suggestions on how to make faster Python implementations of Richards benchmark. Perhaps there are obvious problems that can be corrected? http://www.lissett.com/ben/bench1.htm
14
by: Wolfgang Keller | last post by:
Hello, as a non-developer I am currently participating in an industrial "research" project to develop a so-called "web application". This application serves at the same time as middleware to...
11
by: Wilk | last post by:
Hi, In the page http://www.python.org/dev/doc/devel/whatsnew/node7.html the last sentence says : The net result of the 2.4 optimizations is that Python 2.4 runs the pystone benchmark around XX%...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 419 open ( +3) / 3410 closed ( +2) / 3829 total ( +5) Bugs : 910 open (+12) / 6185 closed ( +5) / 7095 total (+17) RFE : 235 open...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 420 open ( +4) / 3410 closed ( +2) / 3830 total ( +6) Bugs : 915 open (+17) / 6186 closed ( +6) / 7101 total (+23) RFE : 235 open...
7
by: Steve Bergman | last post by:
I'm involved in a discussion thread in which it has been stated that: """ Anything written in a language that is 20x slower (Perl, Python, PHP) than C/C++ should be instantly rejected by users...
4
by: seberino | last post by:
I'm looking over the docs for the re module and can't find how to "NOT" an entire regex. For example..... How make regex that means "contains regex#1 but NOT regex#2" ? Chris
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.