Update locals()

Alex Martelli aleax at aleax.it
Mon Apr 29 02:01:39 EDT 2002


On Monday 29 April 2002 01:05, Brian Quinlan wrote:
	...
> >   may not affect the values of local variables used by the
> interpreter.
>
> The reason that changes to the locals dictionary might not be visible is
> that LOAD_FAST instructions, which are used for local variable lookup,
> use an indexed list and not the locals dictionary.

Right -- and having such change attempts be diagnosed at once (by
making locals() a pseudo-dict that raises on set attempts) would help
debugging.  Similar optimizations to globals() are under consideration
(there are three PEPs out about that, I believe).


Alex





More information about the Python-list mailing list