why python is slower than java?

Maurice LING mauriceling at acm.org
Sat Nov 6 23:15:46 EST 2004


> Not really. It's an impression you could easily get from several
> books about Python (e.g. O'Reilly's "Learning Python"), which
> make a rather big deal about Python being slow to execute, but
> fast to develop in.

Come to think of it, yes, "Python, The Complete Reference", "Programming 
Python" and "Learning Python" all seems to have that "speed warning" tag 
in the beginning chapters.

If this seems to be the wrong impression, should the authors do something?

> 
> The reality is that it isn't really all *that* slow to execute,
> and later versions have gotten quite a bit faster.
> 
> But it remains really fast to develop in. ;-)

I attest to that, at least for the development speed.

> 
> It's quite possible that Java programmers console themselves
> for all the low-level programming work by thinking the result
> will be faster, without really testing to find out.  Certainly
> Java is going to be faster than Jython (Python running on a
> Java platform).

Jython, as I know, wraps each Python objects in a Java class. For 
example, each variable is a class of it own. I suppose this overhead 
does have speed penalities on it, simply because "every dash of cheese 
is calories, even for low fat cheese."

At the same time, Jython FAQ question 1.6 (how fast is jython?) suggests 
that Jython may run 10 times slower than CPython. Personally, I hadn't 
seen this kind of performance in my programs yet. On the other hand, 
"Jython Essentials" suggest that Jython is about 1.5 times the speed of 
CPython (CPython takes about 75% of the time compared to Jython). To 
this, I've also not seen this fast in Jython codes myself. I will say 
that 2-5 times seems to be a reasonable range.

Cheers
Maurice



More information about the Python-list mailing list