relative speed of incremention syntaxes (or "i=i+1" VS "i+=1")

Roy Smith roy at
Sun Aug 21 14:52:50 EDT 2011

In article <mailman.282.1313951079.27778.python-list at>,
 Christian Heimes <lists at> wrote:

> Am 21.08.2011 19:27, schrieb Andreas Löscher:
> > As for using Integers, the first case (line 1319 and 1535) are true and
> > there is no difference in Code. However, Python uses a huge switch-case
> > construct to execute it's opcodes and INPLACE_ADD cames after
> > BINARY_ADD, hence the difference in speed. 
> I don't think that's the reason. Modern compiles turn a switch statement
> into a jump or branch table rather than a linear search like chained
> elif statements.

This is true even for very small values of "modern".  I remember the 
Unix v6 C compiler (circa 1977) was able to do this.

More information about the Python-list mailing list