Python Speed Question and Opinion

Peter Hansen peter at
Tue Jun 8 12:47:29 CEST 2004

Peter Hickman wrote:

> You are correct, it is just that if all you are concerned about is speed 
> then assembler is what you need. 

Jacek already made this point, but I'll make it again.  Assembler
is sometimes *not* the way to write the fastest code.  (Though
sometimes it is.)  Optimizing compilers for some languages such as
C can actually produce *faster* code by choosing combinations of
opcodes and side-effects that even an assembly programmer would be
nuts to use in most cases, largely because it would make the code
even more obscure than it already is but also because they might not
even think of it.

A simplistic example (and one which many x86 programmers learned
about and started using, but probably did not initially) is how
to clear a register.  The chip provided a CLR instruction, but it
actually took (originally, maybe not now) longer to execute than
if one would XOR the register with itself and thus clear it.
There are many other and more complicated examples which compiler
optimizers can use but which are too hard to keep track of for
most assembly writers.


More information about the Python-list mailing list