why python is slower than java?
Lonnie Princehouse
finite.automaton at gmail.com
Mon Nov 8 17:37:08 EST 2004
Mike Meyer <mwm at mired.org> wrote in message news:<x7u0s3r9gz.fsf at guru.mired.org>...
> finite.automaton at gmail.com (Lonnie Princehouse) writes:
>
> > Yes, wxPython is typically quicker than swing. It's not fair to use
> > this in a generic Python-vs-Java speed shootout, though, since
> > wxPython is just a wrapper around wxWidgets' C++ code; you're really
> > comparing C++ vs. Java here.
>
> Is it unfair to compare Python dictionaries to Java HashTables because
> Python is using hand-tuned C where Java is using Java? I'd say that's
> a perfectly fair comparison. If that's fair, what's unfair about
> comparing graphics toolkits that happen to be written in C rather than
> Python (is there a graphics toolkit written in Python?).
>
Perhaps instead of "unfair", I should have written "not meaningful".
Because wxPython is C++ code, you can't really infer that Python is
faster than Java just because wxPython is faster than Swing. The
best meaningful assertion that can be made is that Python can be
faster than Java for GUI operations.
> That's *how* interpreted languages manage to compete with compiled
> languages - they perform the common operations in hand-tuned compiled
> code. That people tend to write Java libraries in Java rather than C
> just means they're going to get slower libraries.
Sure, but it's possible to do the same thing with Java via the JNI.
Maybe what should be compared is the relative ease of writing native
extensions (considerably easier in Python IMHO)
> Java is interpreted just like Python is...
Java bytecodes are interpreted, but javac has the opportunity to do
some optimizations when compiling source into bytecodes that
fundamentally can't be done for Python because it's interpreted.
There's no equivalent of "exec" in Java. Psyco makes a valiant
attempt to do this sort of optimization (and does an excellent job!),
but it's not hard to write perfectly legal Python code that makes
Psyco explode.
[someone correct me if I'm wrong; I'm not an expert Java programmer
:P]
More information about the Python-list
mailing list