Comment

Jan Persson

Python does not stand a chance if you pitch it against C/C++, but as long as you stick to the same kind of languages (i e interpreted, dynamically typed), Python is probably one of the fastest languages around.

For example, does it almost consistently perform better than Perl, TCL and Ruby in all the algorithmic tests in the Computer Language Shootout (http://dada.perl.it/shootout/) and if you pair it together with Psyco you get very close to the speed of a compiled language.

You are right when you say that the performance is not Python's main selling point, but the execution speed is more than often for sufficent for most applications, and for the rest you have a number of options:

* Use Psyco
* Use Pyrex to translate part of you Python code to C
* Write an extension module in C/C++ (e g with the help of SWIG, BOOST)
* Wait for PyPy to be ready... :)

Parent comment

Juri Pakaste

Python has many good things going for it, but I don't think performance comparisons are something the community should be using as selling points. When you expand your comparisons beyond Ruby, you start to find language implementations where the difference isn't quite that favourable...

Replies

Peter Bengtsson

A good thing about Python is the vast amount of optimisation tools like you list Jan. Does perl and ruby have this too?

Python scripts full of complex regular expressions, are they really much faster rewritten in C/C++? For that kind of stuff, isn't python just a simplified API of a big fat C program?

Jan Persson

I'm not that familiar with the tools available for Perl and Ruby, but apart from the JIT (Psyco, which I think is quite unique), I wouldn't be suprised if similar tools existed for those languages, and apart from that, writing an extension module is of course always an option.

Python scripts are often constituted by a number of calls to an optimized C library, where the Python code only works as the "glue" needed to express the program logic. However, this buys us expressivity without having to pay the price of maintaining the complex low level code. John K. Ousterhout (who created TCL) has written a paper about this http://home.pacbell.net/ouster/scripting.html.

This probably the main reason that the Very High Level Languages (VHLL's) are performing as good as they are.

The same thing also apply to Java. Some of the most important classes (String is an example), is almost totally implemented with native code in C, and there is not much perfomance to be gained by making the virtual machine perform better when it comes to string handling.

Isaac Gouy

"The Great Win32 Computer Language Shootout" has not been updated in the last 2 years.

"The Computer Language Shootout" is active, see
http://shootout.alioth.debian.org/benchmark.php?test=all&lang=python&sort=fullcpu

To contribute programs see the FAQ
http://shootout.alioth.debian.org/faq.php?sort=fullcpu#contribute

Peter Bengtsson

So, python occasionally uses more memory but clearly much faster than ruby. Thanks for the link Isaac.