Performances of Pyhton programs
Roy Smith
roy at panix.com
Mon Feb 18 11:18:59 EST 2002
bairef2 at cti.ecp.fr (François Baire) wrote:
> Are there any benchmark or does anoyone know what are the performances of a
> program written in python (in terms of CPU and RAM) compared with other
> languages (especially C++ and compiled languages) ?
> I've met many articles which explain that python programs are slowler
> because it uses the interpreter, but none says how much slower it is ! I
> would like to know this for a rather big OO program which uses standard
> fonctions of the language.
There is little doubt that a program written in C/C++ will be faster than
the same algorithm implemented in Python (or any of the common "scripting"
languages such as Perl or TCL). How much slower depends to a very large
degree on exactly what you're doing.
I've got one program in Python which is probably 100x slower than a C
version because it does a huge amount of low-level string manipulation
(building up strings character by character) which is exactly the wrong
thing to be doing in Python. When I profile it, over 99% of the CPU time
is spent in the string module. But, that means it takes 3 seconds to run
instead of a fraction of a second, and it saved me days of development time.
On the other hand, I've written Python database applications which
essentially ran at the same speed as a C version would because all the hard
work was really being done inside Oracle.
You might want to check out http://www.bagley.org/~doug/shootout/ for a few
random datapoints.
More information about the Python-list
mailing list