[pypy-dev] [mdione at grulic.org.ar: modifying locals]

Armin Rigo arigo at tunes.org
Thu Oct 15 16:14:02 CEST 2015


Hi Marcos,

On Wed, Oct 14, 2015 at 12:58 PM, Marcos Dione <mdione at grulic.org.ar> wrote:
> inception_locals= sys._getframe().f_back.f_locals
> inception_locals.update (locals)

I think this works if you *assign* to f_locals.  When you only *read*
f_locals, you get a copy of the dict.  The assignment is needed to
write the new values back into the frame's real ("optimized") locals:

    inception_locals= sys._getframe().f_back.f_locals
    inception_locals.update (locals)
    sys._getframe().f_back.f_locals = inception_locals


A bientôt,

Armin.


More information about the pypy-dev mailing list