Hi Antonio (and others)

As you have probably seen, we started work on list support for
ootypesystem here at the ongoing Leysin sprint. This cleared things up a
bit for me on the conceptual level. Here's how OO lists work:

- There is a new type constructor "List" in the ootype module. The
low-level type of RPython list in the ootypesystem is a List instance
with the item type of the list provided as an argument. E.g., an RPython
list of integers has the low-level type List(Signed).

- The interface of an OO list is defined by List._METHODS (see
List.__init__). This interface is still incomplete, but it should be
kept as small as possible, but large enough to support all operations
permitted in RPython on lists.

- When it comes to low-level operations, Lists are treated similarly to
Instances. "new" is used to instantiate an (empty) list. Methods of the
interface are rtyped as "oosend" operations with the name of the method.

- Backends must special-case "new" with Lists and "oosends" to Lists.
Basically, "new" can be mapped to the construction of a native list in
the backend. The oosends can be mapped to native methods of the native list.

All of this works for some basic list operations at this point (length,
append, getitem, setitem), but there's still quite a bit of work to do
for full list support in ootypesystem.

After all this, the roadmap for bringing all other data structures to
ootypesystem is now pretty clear to me:

- dicts: Can be implemented analoguous to lists (type constructor,
minimal interface etc.)
- strings: Analoguous to lists, but no type constructor necessary
- ranges, slices: Can be implemented as a special Instance (analoguous
to tuples, in a way)

I have two more days here at the Leysin sprint to work on lists. After
that I again won't have much time to work on PyPy, so Antonio (or anyone
else), you're very welcome to continue from here. I think the list code
can serve as a good starting point for the other data structures. If
there are any questions, I'm happy to answer them (if I can ;)).

Cheers
Nik
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev

Reply via email to