Hi Armin, Thanks for looking into this. Is this pre-translation code a general thing possible with any RPython based compiler, or is it very PyPy specific?
Cheers, Magnus > On 16 Mar 2016, at 08:45, Armin Rigo <ar...@tunes.org> wrote: > > Hi Magnus, > > On 16 March 2016 at 01:37, Magnus Morton <m...@magnusmorton.com> wrote: >> You can recreate it in PyPy by putting the following two lines pretty much >> anywhere in interpreter level code other than the >> setup_after_space_initialization methods >> >> from pypy.module.pypyjit.hooks import pypy_hooks >> pypy_hooks.foo = “foo” >> >> What I can’t understand is what is special about the >> setup_after_space_initialization methods that makes it work there. > > Reproduced and figured it out. Added some docs in eda9fd6a0601: > > + # WARNING: You should make a single prebuilt instance of a subclass > + # of this class. You can, before translation, initialize some > + # attributes on this instance, and then read or change these > + # attributes inside the methods of the subclass. But this prebuilt > + # instance *must not* be seen during the normal annotation/rtyping > + # of the program! A line like ``pypy_hooks.foo = ...`` must not > + # appear inside your interpreter's RPython code. > > In PyPy, setup_after_space_initialization() is not RPython (which means > it is executed before translation). > > > A bientôt, > > Armin. _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev