You Are Here:

Community: Developer Discussion Boards

#1 Old Performance od Python - 2008-02-04, 11:01

Join Date: Apr 2005
Posts: 75
Kurt Johannes
Offline
Regular Contributor
Hi,

I am new to Python so I implemented some simple applications to see the performance of Python in comparison to Java and Symbian. Therefore I just programmed some for loops with some simple mathematical operations (subtraction, multiplication) to see the difference to other platforms.

I was suprised that Python is really slow compared to other languages. Of course, I know, it is interpreted but it is ~15 times slower than java and much more slower than Symbian.

Is it really that slow or am I doing something wrong?

Code snippet:

v1 = [..20 float values]
v2 = [..20 float values]

for i in range(100000):
for j in range(20):
d = v1[j]-v2[j]
dd = d*d
Reply With Quote

#2 Old Re: Performance od Python - 2008-02-04, 16:34

Join Date: Dec 2004
Posts: 646
jplauril's Avatar
jplauril
Offline
Forum Nokia Expert
Try using xrange instead of range. That may improve performance a little bit. But yes, Python is slower than Java or C++. You should always try to perform mathematical heavy lifting using native modules instead of coding it elementwise in Python.
Reply With Quote

#3 Old Re: Performance od Python - 2008-02-04, 21:42

Join Date: Jan 2004
Posts: 368
Location: Helsinki
Send a message via Skype™ to miohtama
miohtama's Avatar
miohtama
Offline
Regular Contributor
Quote:
Originally Posted by Kurt Johannes View Post
Hi,

I was suprised that Python is really slow compared to other languages. Of course, I know, it is interpreted but it is ~15 times slower than java and much more slower than Symbian.
Instead of for loops try use map, filter and other built-in Python mapping operations. They lift the loop iteration to the native code and perform faster.

If your math code is performance sensitive, move crucial loops to the native C++ extension. This way you get the absolute processor speed, the same as in native C.

Cheers,
Mikko


Mikko Ohtamaa
Twinapex Research
http://www.twinapex.com
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help installing Python libraries on S60 ericroijen Python 11 2009-07-18 11:43
[announce] PyUIQ. Python for UIQ 2.1 and 3.x OscarBernabeu Python 35 2008-01-17 10:12
[announce] the first Mobile Python book is now available ! cyke64 Python 1 2008-01-08 10:58
[announce] Mobile Python book soon in Sept 2007 ! cyke64 Python 11 2007-10-03 20:46
(Re)associating Python scripts with Python in messaging? RaimondasL Python 3 2007-03-13 07:50

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia