Python interpreter speed

Fabio Zadrozny fabiofz at gmail.com
Tue Apr 21 13:24:51 EDT 2009


> Further, I have an accounting software which was previously in java, but
> now in python and the performance gain is ausom.
>
> Yes it depends on how we write the code but comparing the 2 at least at
> the middle layer and front-end (pygtk) python is faster than java.
> Infact I am most certain that swing is not even 50% as fast as pygtk or
> pyqt.

Actually, pygtk and pyqt are mostly wrappers for c/c++ code (wrapping
c/c++ is much easier in python than in java... so, that example ends
up comparing java to c/c++ and not python).

Java is usually faster in general (because of the many optimizations
SUN did in the Java VM through many JIT techniques), although it has a
slower startup time (which is a drawback of that same JIT), so, some
applications can actually be faster in python just because of the
faster startup time (like command line utilities), but for
applications that keep running for more time, Java is usually faster
-- even more if you don't  use a mix of python and c/c++.

Still, as you noted, if you take into account that you can rewrite
your slow parts of the application in a faster language and just make
python bindings for it, that advantage is largely diminished (while
still having a fast startup time), and as you profile you can see that
it's usually just 1% of the application that takes up 90% of the time.
So, it's not a major drawback, and if you develop faster in python
then it's worth it... (but I'd hardly say that rewriting from java to
python will make it faster... if it becomes faster it's because you
used better algorithms).

Anyways, a program is usually faster/slower because of your choice of
program structure and algorithms and not because of the speed of the
language anyways.

Cheers,

Fabio



More information about the Python-list mailing list