[pypy-dev] extension compiler and Python special methods

Armin Rigo arigo at tunes.org
Thu Jul 27 11:58:25 CEST 2006

Hi Lawrence,

On Thu, Jul 27, 2006 at 11:20:02AM +0200, Lawrence Oluyede wrote:
> > That's fine.  Note also that you can use special method *names* in
> > RPython code, you just have to call them explicitly.
> Is it some sort of coding style rule? I think is ok but sounds like a
> duplication of code to me now...

Well, as long as we have to write the space wrappers by hand, but would
also like the "pure" method to be available, there is going to be this
kind of duplication :-(  At some point, the unwrap_spec could be
enhanced to cover much more automatic wrapping and unwrapping; then
we'll be able to use the "pure" method directly, as in:

    class X:
        def __len__(self):
            return 42
        __len__.unwrap_spec = ['self'], 'returns an int'  # or whatever

and directly point to the __len__ method in the TypeDef, getting rid of
all explicit references to 'space' in the simple methods.

A bientot,


More information about the Pypy-dev mailing list