Python is faster than C

Paul Prescod paul at prescod.net
Mon Apr 5 06:09:36 EDT 2004


Matthias wrote:

>...
> 
> Isn't the whole idea of very high level languages to shift complexity
> from the user code to the language implementation?  

Shift code, yes. Shift complexity? Not necessarily. Ideally both the 
language implementation and the programs that use the implementation are 
both simple. Unoptimized code tends to be simpler than heavily optimized 
code. If you can get away without optimizing either then you win.

> That's not a rhetorical question: Why is it that "simplicity of the
> Python VM is an important goal"? 



> ... I would guess that overall it pays
> to have a more complex language implementation and be rewarded by
> simpler user code: For any decent language there's much more user code
> out there than language implementation code.

It pays whom? The relatively tiny team of volunteer maintaining the 
Python interpreter? The team at Nokia porting it to cell phones? Jim 
Hugunin porting it to the .NET platform? The Jython guys?

"C is a programming language designed for writing Unix, and it was 
designed using the New Jersey approach. C is therefore a language for 
which it is easy to write a decent compiler, and it requires the 
programmer to write text that is easy for the compiler to interpret. 
Some have called C a fancy assembly language. Both early Unix and C 
compilers had simple structures, are easy to port, require few machine 
resources to run, and provide about 50%--80% of what you want from an 
operating system and programming language.

  Half the computers that exist at any point are worse than median 
(smaller or slower). Unix and C work fine on them. The worse-is-better 
philosophy means that implementation simplicity has highest priority, 
which means Unix and C are easy to port on such machines. Therefore, one 
expects that if the 50% functionality Unix and C support is 
satisfactory, they will start to appear everywhere. And they have, 
haven't they?

  Unix and C are the ultimate computer viruses."

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

Python is the next viral tchnology.

> One example where Python in the past made (in my opinion, for my
> particular projects) the wrong choice is speed: People argued that
> "simplicity of the Python VM" is more important than speed gains.  The
> result (for my code) was that after profiling, etc., I was coding
> significant parts of my programs in C.  No productivity gain
> observed. With JIT compilation (psyco) this step might become
> unnecessary: More complex VM, greatly simplified user code.

That's why it is great that there are things like Pyrex and Pysco for 
you to use. The fact that you can benefit from them without making 
Guido's life harder (or that of Nokia or ...) is even better!

  Paul Prescod






More information about the Python-list mailing list