Is python really slow?

Peter Hansen peter at engcorp.com
Tue May 21 22:08:34 EDT 2002


Chris wrote:
> 
> 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 ...
> Is this just because ... Python [is] 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.

As others have noted, Python is the same speed as Perl, and the
use of C comes more from the desire to integrate with other 
software than from a need for improving on Python's speed.

My comment is that in 2.5 years of writing Python code, with a
group averaging eight developers during that time all writing Python, 
the only time we have had to write C code to work with Python was 
to interface with a dual-port RAM device in an embedded system in 
which we use Python -- not because of speed concerns.

We use Python for web work (via Zope), factory automation, utilities,
GUI applications, embedded systems and other areas.  We pretty
much cover the range, and have not yet found a reason to write
any C code.  Those who do for performance reasons are generally
working in specialized areas (e.g. image processing) or they 
may be optimizing prematurely.

In any case, compared to the other "P" languages you mention, 
Python is definitely not slower.  Note however that none of 
those other languages, including the "C" one :-), would be
as suitable for such a wide range of application areas as Python.

-Peter



More information about the Python-list mailing list