[pypy-dev] setting attribute of JitHookInterface instance
Armin Rigo
arigo at tunes.org
Wed Mar 16 04:45:56 EDT 2016
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