Hi Armin, It seems that with your suggestions, things have started to work!
Thanks again for the help! On Mon, Dec 19, 2016 at 5:57 PM Armin Rigo <armin.r...@gmail.com> wrote: > Hi Frank, > > On 20 December 2016 at 01:29, Frank Wang <fra...@mit.edu> wrote: > > This also seems to happen in a lot of classes because W_Root is the > parent > > class for many classes. Is there a way to universally turn off this > > immutable flag (assuming it's okay) in all classes? > > You can hack at the place where the error is raised. Assuming you're > translating without the JIT, it should not cause too much problems. > > As an alternative to adding an attribute to every object, you could > also use a rpython.rlib.rweakref.RWeakKeyDictionary(W_Root, RbFlags), > for some class RbFlags which has got the rb_flags dictionary and/or > any other related data. The advantage is that it is a less intrusive > change, reduces memory usage if many objects don't need the extra > information at all, and avoids the immutable problem. The > inconvenient is that going from the object to the rb_flags dictionary > is slower. > > There are also alternatives that are better if you are ok with > supporting not *all* objects. For example, you can edit > objspace/std/mapdict.py to add a new dynamic attribute that is > internally called ``"rbflags", SPECIAL``; see ``"weakref", SPECIAL`` > for an existing example. This would work for all objects that use > mapdicts, i.e. all instances of user-defined classes, and additionally > instances of many built-in types as well---but not instances of the > core types like "int" or "str" or "list" or "tuple" or "dict". > > > A bientôt, > > Armin. >
_______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev