Is python really slow?

Delaney, Timothy tdelaney at avaya.com
Tue May 21 21:08:44 EDT 2002


> From: Chris [mailto:chrisl_ak at hotmail.com]
> 
http://www.python.org/doc/Comparisons.html

> I am a bit 
> disheartened at how common it seems to code only some of a program in 
> Python and use C for other parts, and how much discussion 
> here involves using C for X and Y.

It is actually quite rare for most people using python to explicitly use
C<->Python directly. There are many modules which are written in C, however
for most users this is completely transparent - from Python they behave
exactly the same as a module written in Python.

> language. I don't 
> see nearly as much discussion about doing this in the Perl newgroups. 

That would probably be because it's a lot harder to do in Perl. It is
actually quite easy to write extensions in C for Python which will work on
every platform that Python itself runs on.

> Should I just be learning C instead? Is this just because of 
> the different 
> applications python is being put to use for or because Python 
> programmers 
> are more "multi-lingual" or is Python really so slow that one 
> needs to go 
> to C on a more regular basis?

Definitely do not learn C *instead* of Python. Python programmers do tend to
"use the best tool for the job". In most cases, the best tool is pure
python, using modules (e.g. Numeric Python) which are written in C/C++ to
improve performance when needed.

Most of the discussions you see are from people who are writing modules for
others to use, or who are investigating the Python codebase or C extension
codebase to scratch an itch.

Python is normally "fast enough", and in general is about the same
performance as perl (of course, the actual performance depends on the
specific task and the algorithm chosen). Most of the time poor performance
is due to a poor algorithm - it is much easier to get the algorithm right in
Python than in most languages.

Tim Delaney





More information about the Python-list mailing list