Performance java vs. python
gunterhenriksen at gmail.com
Wed May 20 00:56:38 CEST 2009
My experience has been that if the execution stays
inside the VM, then for a "server side" application, the
JVM is faster, and proportionally even faster when there
are more threads ready to do something.
When the VM has to do a lot of interaction with the
OS, then I think it is difficult to make general
statements about Java vs Python, because there is so
much dependency on how a particular library interacts
with the operating system or with a remote server.
For example a database driver which is doing a lot
of conversion between the data representation of the
database and the native representation of the VM may
chew up more time than anything else, and for CPython
that driver may be doing all that stuff in a C library
where the Java version of the driver may be doing it all
in the JVM and taking an order of magnitude longer.
It seems to me like the guts of the JVM and CPython
VMs are pretty comparable in terms of performance, and
both languages are amenable to taking advantage of the
performance of the VM.
Other than the library implementations for interfacing
with the outside world, for me the major performance
distinction is with concurrency. I tend to implement
solutions which rely pretty heavily on shared objects
and the java.util.concurrent facilities, and it seems
to me like the CPython VM is not able to easily provide
the level of simple clean shared object concurrency
support the JVM does. And my experience with the Python
"multiprocessing" module is that while it is better than
nothing, it does not seem to facilitate nearly the level
of efficient shared object support the JVM does.
More information about the Python-list