[pypy-dev] setting attribute of JitHookInterface instance
Magnus Morton
m at magnusmorton.com
Wed Mar 16 07:34:55 EDT 2016
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 <arigo at tunes.org> wrote:
>
> Hi Magnus,
>
> On 16 March 2016 at 01:37, Magnus Morton <m at 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.
More information about the pypy-dev
mailing list