Java vs Python Benchmarks: Java is faster

Kragen Sitaker kragen at pobox.com
Sun Feb 3 01:10:37 EST 2002


"Steve Holden" <sholden at holdenweb.com> writes:
> Without any introduction of static typing into the language, it's extremely
> unlikely that a JIT would yield the same benefits as it does for Java,
> although recent experiments with compiler techniques have shown interesting
> speedups on restricted cases.

This is completely unfounded and false.  The JIT techniques used for
Java were developed for Self, a language just as dynamic as Python,
and compiled Self code to within a factor of 2 of C --- the same kind
of speed Java JITs get today.  The Self experiments were carried out
during the late 1980s and early 1990s, and they were not "restricted
cases".

> The major problem is that with dynamic (latent) typing, the JIT code has to
> examine the type of its operands in order to determine which of several
> type-based operations to perform. Java can avoid this due to its strong
> typing mechanism. [inflammatory remark snipped]

Java can avoid this in some cases, because the types of some variables
(those of primitive, non-Object types) are known at compile-time, but
just like Python, the types of most objects are not known at
compile-time; most classes and most methods are not final.  It's
optimizing these dynamic calls that is hard.

It's true that Java objects all have declared types, but that doesn't
save you as much as you'd think; it just allows more efficient dynamic
method lookup in cases where the JIT can't do anything smarter --- but
it's still too slow.




More information about the Python-list mailing list