[Python-Dev] Possible optimization for LOAD_FAST ?

Ned Batchelder ned at nedbatchelder.com
Mon Jan 3 02:25:56 CET 2011

On 1/2/2011 8:17 AM, Victor Stinner wrote:
> Le mercredi 29 décembre 2010 à 14:20 +0100, "Martin v. Löwis" a écrit :
>> Am 28.12.2010 18:08, schrieb Lukas Lueg:
>>> Also, the
>>> load_fast in lne 22 to reference x could be taken out of the loop as x
>>> will always point to the same object....
>> That's not true; a debugger may change the value of x.
> That's why Python has the following option:
> -O     : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x
> I regulary recompile programs with gcc -O0 -g to debug them. It is very
> difficult to debug (with gdb) a program compiled with gcc -O2: many
> variables are stored in registers, and gdb doesn't support that
> correctly.
Victor, you seem to be equating the gcc -O flag with the Python -O 
flag.  They are described similarly, but can't be used the same way.  In 
particular, there is no Python equivalent to gcc's -O0: there is no way 
to disable the Python peephole optimizer.

> Victor
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/ned%40nedbatchelder.com

More information about the Python-Dev mailing list