why python is slower than java?

Jon Perez jbperez808 at wahoo.com
Thu Nov 11 00:36:18 EST 2004


First of all, I really really really love Python but unlike
the other people posting on this thread I am not allergic
to criticisms of python and I feel the attitude of
some on this list is way too defensive and actually
works against the outside perception of the language.
(OTOH, what I saw on this thread is still considered mild,
you should see those LISPers defend their language! :-D )

Anyway, on to the topic at hand.  I actually don't
believe python is slower than java.  But truth to
tell, the answer can never be a simple 'one is faster
than the other'.

In the cases where Python is slower than Java, it
is because Java is JIT-compiled whereas Python by
default is bytecode-interpreted (unless you use Psyco).

In the cases where Python is faster than Java, it
is because much of Python's core and library functionality
is actually coded very efficiently in C, and said
code path is using much of this functionality.

When it comes to the language proper, Java is just
way more primitive than Python, and considering
that the speed of both will be *** of roughly the same
order ***, I'll take Python any day.

The fact that you can much more easily use and write
Python C extensions (still not exactly a picnic though)
than JNI ones is yet another speed-related thing in
favor of Python over Java.


Maurice LING wrote:
 > This may be a dumb thing to ask, but besides the penalty for dynamic
 > typing, is there any other real reasons that Python is slower than Java?
 >
 > maurice



More information about the Python-list mailing list