Is python really slow?

David K. Trudgett dkt at registriesltd.com.au
Tue May 21 21:22:53 EDT 2002


On Wednesday 2002-05-22 at 00:54:02 -0000, Chris wrote:

> I spend a fair amount of time on perl newsgroups, having the need to use 
> perl for various parts of my job. I am now learning Python. 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. I don't have time to learn another language. I don't 
> see nearly as much discussion about doing this in the Perl newgroups. 
> 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?
> 
> This is NOT flamebait... it just has me concerned that by deciding on 
> Python (after becoming semi-proficient in PHP and Perl) I might be making a 
> mistake.

Well, of course Python is going to be about an order of magnitude or
more slower than C just because of its interpreted nature. But, then,
it takes an order of magnitude more time to develop an application in
C, generally speaking.

For most applications, this speed difference doesn't matter too much,
and it's more important to get the application done quickly.

The same reasoning goes for Perl, though I find Perl to be generally
faster than Python for what I do with it [completely unscientific, take it
with a grain of salt], which is mostly text processing tasks, but plenty
of other things, as well, like TCP/IP network daemons.

There will often be places in a program that require speed, or that
must be written in a lower-level language for some other reason. I
don't see this as a problem, though. Why should one write the whole
application in C just to optimise 2% of it?

The bottom line is, not everyone can expect to do everything in Python or
Perl, and so C is the natural choice to supplement the capabilities of
the higher-level languages.

By the way, C is a "small" language and not hard to learn. It might be
hard to learn to program *well* in it, but that's another story. :-)

David Trudgett








More information about the Python-list mailing list