[pypy-dev] special methods

Armin Rigo arigo at tunes.org
Thu Mar 29 19:35:35 CEST 2007

Hi Simon,

On Thu, Mar 29, 2007 at 10:18:06AM -0700, Simon Burton wrote:
> What is your concern here ? Does it screw up the JIT, or some other aspect
> I am missing ?

No, just the obscurity of these methods: the full Python
__add__/__radd__ semantics are more than a little tricky.  They are
impossible to implement statically, because in order to know which one
to call first you need to know the two exact subclasses of the
arguments, which you only know at run-time.

The RPython approach so far has at least a clear message: no special
methods, apart from __init__() and __del__().  I'm not against adding a
few of them, to be honest; e.g. __getitem__() would be my favorite.  But
then they should be fully implemented.  For example, I just realized
that without the full rtyper solution, your patch can work for str(x)
but not for '%s' % (x,), which looks rather inconsistent.

A bientot,


More information about the Pypy-dev mailing list