| Reply | « Previous Thread | Next Thread » |
|
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 |
| Kurt Johannes |
| View Public Profile |
| Find all posts by Kurt Johannes |
|
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.
|
|
Quote:
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| 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 |