[Python-Dev] Silly pystones question

Skip Montanaro skip@pobox.com (Skip Montanaro)
Fri, 10 Aug 2001 21:43:44 -0500

In pystones.Proc0, most of the variables declared global are never assigned.
Was that just slavish adherence to the style of code from which it was
adapted or was the code changed at some point in the past, making the global
declarations superfluous?  Seems to me that the only time the global keyword
should be used is when an assignment to the variable occurs in the code and
you want to make sure you're modifying the global name.

This is obviously a silly piece of code in which to question this technique,
but I was looking at it to gauge the effects of possible global object
access optimization.  My first assumption was that a variable declared
global wouldn't be subject to any optimization, but now I realize I'd have
to look for variables that were operands of LOAD_GLOBAL instructions but not
STORE_GLOBAL instructions.