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

Christian Heimes lists at cheimes.de
Sun Aug 21 20:24:17 CEST 2011


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. Python 3.2 on Linux should also be compiled with
computed gotos.

Christian




More information about the Python-list mailing list