Python is faster than C

Paul Prescod paul at prescod.net
Sun Apr 4 23:59:54 EDT 2004


Armin Rigo wrote:

>...
> 
> is among the easiest to optimize, even if the language specification said that
> enumerate returns a list.  I can think of several ways to do that.  For
> example, because the result of enumerate() is only ever used in a for loop, it
> knows it can internally return an iterator instead of the whole list.  There
> are some difficulties, but nothing critical.  Another option which is harder
> in CPython but which we are experimenting with in PyPy would be to return a
> Python object of type 'list' but with a different, lazy implementation.

Here's the question: given that most programmers do think about 
performance, is their mental load reduced by putting in a bunch of 
special cases that may or may not be triggered in various situations or 
by giving them a very tightly defined language feature with predictable 
performance characteristics?

For instance I sometimes program in XSLT. Its a very declarative 
language where one could imagine an amazing number of automatically 
applied optimizations. But I have no way of knowing whether my XSLT 
implementation supplies them (I seldom uses profilers in general and I 
don't believe that most XSLT implementations have profilers at all). And 
even if I did know what a particular XSLT implementation did, I wouldn't 
know whether another did it. This leaves me with a vague uneasy feeling 
that I don't know whether my code is going to blow-up when faced with 
large datasets or handle them well. Sometimes I program my XSLT in a way 
that has predictable runtime characteristics even if I know that it will 
disable the optimizer...at least I don't have to worry about getting 
worse-case behaviour either!

I prefer Python because it is more transparent.

Also, there is the question of interface simplicity versus 
implementation simplicity that is discussed here:

  * http://www.jwz.org/doc/worse-is-better.html

Python tends to err on the side of implementation simplicity. (it may 
not be a coincidence that it was an MIT guy who added nested scopes 
after Guido chose not to prioritize it over Python's first several years 
of existence)

  Paul Prescod






More information about the Python-list mailing list