YATOPS (Yet Another Thread on Python's Speed) (was Re: HELP! Must choose language!)

Peter Hansen peter at engcorp.com
Thu Jan 2 15:26:04 CET 2003

Yu Wang wrote:
> For commercial usage, ( sorry, I would say it twice ), python program is
> simple, clear, maintainable..., but it's slow. 

As a developer of commercial software written in Python, I have to say
that Yu Wang's statement about Python's speed is simply not always true.   
I would even venture to suggest that it is only rarely true.

If you were to change the above to say "but it's slower than C" it would be true...

> C/C++ ( sorry again, I would take c/c++ as example because I'm now using 
> them ) is rather faster and flexible.  Sometimes, people choose language 
> just by run-time speed.

These two statements are both true.  Clearly C is faster.  In fact, that's
a good thing to know when developing Python code, so that *IF* you reach
the point where the performance of your Python program is too slow (**),
then you can always fall back on a little well-conceived C extension to
solve the problem.  It's never a reason to abandon Python completely.

** "too slow" is almost always defined incorrectly.  In most cases,
it means "I think this should run faster".  In fact, it should be 
defined as "my customers *require* that this run faster" or something 
more like that.  Most developers are wrong about how fast things 
really need to run... (maybe because they have no requirements.)

Another key point is that most people start to optimize their code
*without* having profiled it first, and *without* making sure the 
code is actually working properly first (i.e. "finished") .  
Optimization without profiling is always bad and, to quote Knuth
yet again, "Premature optimization is the root of all evil."

See also http://billharlan.com/pub/papers/A_Tirade_Against_the_Cult_of_Performance.html

> I'm not saying python is not fit for commercial usage. In fact, I have
> seen several  successful stories about python projects. But, in my memory, 
> they are still somewhat "private projcet" done by one or two or several guys. 
> ( mostly, one person enough ). 

Our projects are certainly private, but they have involved the effort
of at this point over twenty different Python programmers, sometimes 
as many as ten at a time.  And some of them are female, too. ;-)


More information about the Python-list mailing list