Niklaus Haldimann wrote:
Oops, I didn't intend to invalidate your work. ;) I actually checked
your user directory yesterday, because you said in an earlier mail that
you would work on the branch there. But since I didn't see any changes
related to rlist I assumed you decided to postpone this ...
No, I was working on that but I didn't commit because I wanted to get
all things working before doing that... I've had some problem fixing all
various modules that accessed rpython.rlist directly.
What you did doesn't look so bad, I just looked at it. In general, I'm
impressed that you found your way around the RTyper so easily. ;)
Don't worry, it has not been so easy! :-)
The
main difference to our work is that you created many new low-level
operations for the list interface. Since there will also have to be a
dict and string interface this would lead to an explosion of low-level
operations. Our approach also makes testing of these data structures at
a lower level easier (see test_oolist.py and test_oortype.py).
The reason beyond that is that I've found no other way to do this: I
really wanted to create as few low-level ops as possibile, but I coudn't
figure out how to do. I try to explain better what I did: my first
attempt was to provide a low-level operation 'list_lenght' and then
implement rtype_is_true in terms of 'list_lenght', so I wrote a thing
like this:
class ListRepr(AbstractListRepr):
def rtype_len(self, hop):
v_lst, = hop.inputargs(self)
return hop.genop('list_len', [v_lst], resulttype=Signed)
def rtype_is_true(self, hop):
v_lst, = hop.inputargs(self)
return hop.gendirectcall(ll_list_is_true, v_lst)
def ll_list_is_true(lst):
return lst is not None and len(lst) != 0
I hoped that the rtyper was smart enough to convert 'len(lst)' into my
low-level op 'list_len', but it wasn't: indeed, it generated code that
called len function for a generic PyObject* and that was not what I wanted.
I tried to copy the implementation of
lltypesystem.rlist.ll_list_is_true, but I couldn't because that can call
the ll_lenght() method that I didn't have. Now it has no longer
importance, but how could I do to get thing working?
ciao Anto
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev