[pypy-dev] Support for __getitem__ in rpython?

Paolo Giarrusso p.giarrusso at gmail.com
Mon Dec 29 20:55:52 CET 2008

On Mon, Dec 29, 2008 at 16:15, Hakan Ardo <hakan at debian.org> wrote:
> On Sat, Dec 27, 2008 at 7:45 PM, Armin Rigo <arigo at tunes.org> wrote:
>> You can try, but it's messy.  It's not a problem for the annotator but
>> for the later RTyper.  None is implemented as a NULL pointer by the
> Atatched is a small patch for the annotator that makes it treat None
> and NotImplemented alike. This is all that is needed for most cases as
> all NotImplemented are typically removed by the optimisations
> performed by the annotator.
That can be made to work, but if such a method returns None you get
completely different semantics (trying again with something else) from
CPython (which will maybe return a failure, or return None for the
result of such an operation), so you have to restrict the allowed
semantics in RPython to the "most cases" you are referring to.

Basically, I'd propose that in RPython with your patch, those methods
(__add__ etc.) cannot return None (I can't think of a possible use
case for an addition returning None), while I guess NotImplemented can
only be returned by them, and not by any other function or method (do
the current sources ever use NotImplemented?). There must be no
function which can choose to return None or NotImplemented.

Paolo Giarrusso

More information about the Pypy-dev mailing list