[SciPy-dev] Re: Scipy-dev digest, Vol 1 #86 - 7 msgs

Pat Miller pnmiller at pacbell.net
Mon Feb 11 23:37:28 CST 2002

Pearu writes:
 >Pat wrote:

>>It is a bit tricky as you cannot just use python tricks to update
>>the local dictionary for affect:

> See http://www.python.org/doc/current/lib/built-in-funcs.html:
> locals() 

I know all about this...  the value that locals() returns is
actually computed on the fly and stashed into an attribute
of the code object.  It mirrors the elements of a local
stack that is built on executing the code frame (that is why
changing it doesn't affect the state, the dictionary is
a one way reference to the frame.

> And I think you should not modify locals() dictionary from Python
> C/API either.

The point is to get things like
a = 3
weave.inline("a += 1")

to update the value of 'a' as if the code were written

a = 3
a += 1

And it really should be done inside the C API because of speed
concerns.  In some sense, the weave.inline is _really_ a
specialized replacement for the __builtin__ exec function.
This means that the point is to muck with the local and global


More information about the Scipy-dev mailing list