Java vs Python performance

By geoffoc

Always good to provide some non-scientific comparative performance data – tends to rub people the wrong way, but here goes anyway :-)

Anyway, http://www.twistedmatrix.com/~glyph/rant/python-vs-java.html detailed a quick performance evaluation that I thought was ’sort of ‘ useful for some research I was doing – then I saw the date on the page – 2000 – which is shall we say, a ‘tad’ old. So I thought i’d re-run the tests on a current platform, in this case Ubuntu 7.10 ‘Gutsy’. As i’m only interested in the performance ratio between Java and Python rather than the overall performance increase due to improvements in underlying hardware i’ve converted the results on the previous web page to a ratio (Java/Python) as well to see how the systems have changed in the last 7 years.

Test Ratio (Java/Python) in 2000
Standard Output 4.54
Hashtable 2.06
I/O 1.19
List 0.31
Interpreter Init 6.25
Object Allocation 0.11
Interpreter Speed 0.18

As you can see from those numbers (>1) that Java was considerably slower than Python in the arbitrary tests performed. As I was a little curious to see it for myself I re-ran the code detailed on the page on my fresh gutsy system albeit with an openjdk code drop just to see if things had changed and how.

Test Ratio (Java/Python) in 2007
Standard Output 2.20
Hashtable 0.64
I/O 0.38
List 0.42
Interpreter Init 12
Object Allocation 0.034
Interpreter Speed 0.86

As you can see Java has improved in most of the tests so that it now significantly outperforms python. I guess the major disappointment is the Interpreter initialization which seems to have gotten significantly worse :-( but overall Java performance has according to these tests improved relative to python.

Please note that I haven’t looked at the suitability of the tests themselves, merely re-run them for myself to try and improve my understanding – i’ve released it here so that there is at least a recent counterpoint to the 2000 article. Flames >/dev/null please

2 Responses to “Java vs Python performance”

  1. The empire strikes back…. or does it? « MrPointy’s Weblog Says:

    [...] chuckle from the completely non-scientific way of benchmarking Java versus Python in a previous posting. Anyway, to further rub salt into the wounds we can have a look at the results from the Debian [...]

  2. Cognitive Cow - » In Defense of the Java Giant Says:

    [...] is slow. No it’s not. Python is much much slower. The neat little features of Python do come at a price and a pretty hefty one. I [...]

Leave a Reply