[pypy-dev] Support for __getitem__ in rpython?
hakan at debian.org
Thu Dec 4 10:15:34 CET 2008
I've started to play around with the pypy codebase with the intention
to make obj[i] act like obj.__getitem__(i) for rpython objects. The
approach I tried was to add:
class __extend__(pairtype(SomeInstance, SomeObject)):
def getitem((s_array, s_index)):
and then do something like:
class __extend__(pairtype(AbstractInstanceRepr, Repr)):
def rtype_getitem((r_array, r_key), hop):
hop2.forced_opname = 'getattr'
hop3.forced_opname = 'simple_call'
But I am having a hard time understanding the rtyper and if this is
the right approach? Is there anything similar in the code/docs I
could look at to get a better understanding on how to write this?
Would it be a better solution to add an intermediate step between the
annotator and the rtyper that converts
Any suggestions will be appreciated. Thanx!
More information about the Pypy-dev