[Python-Dev] frame.f_locals is writable

Shane Holloway (IEEE) shane.holloway at ieee.org
Fri Jan 14 18:17:23 CET 2005


Brett C. wrote:
> Other option would be to add a function that either directly modified
>  single values in f_localsplus, a function that takes a dict and 
> propogates the values, or a function that just calls 
> PyFrame_LocalsToFast() .
Brett!!  Thanks for looking this up!  With a little help from ctypes, I 
was able to call PyFrame_LocalsToFast, and it works wonderfully!  Maybe 
this method could be added to the frame type itself?


> Personally I am against this, but that is because you would 
> single-handedly ruin my master's thesis and invalidate any possible
> type inferencing one can do in Python without some semantic change.
> But then again my thesis shows that amount of type inferencing is not
> worth the code complexity so it isn't totally devastating. =)
Well, at least in theory this only allows the developer to replace a 
variable with a better (hopefully) version of a class that is very 
similar...  <wink>


 > And you are right, "don't do that".  =)

I'm going to only remember this trick in the light of development tools. 
  Really!  This magic is WAY too deep for a library.  The only use for 
it that I could really see is a smalltalk-like swap method.


Thanks again for your help!
-Shane



More information about the Python-Dev mailing list