[pypy-dev] extension compiler and Python special methods

Armin Rigo arigo at tunes.org
Thu Jul 27 11:17:07 CEST 2006

Hi Lawrence,

On Tue, Jul 25, 2006 at 08:51:09PM +0200, Lawrence Oluyede wrote:
> As u can see in rev. #30543 I commited a series of methods to complete
> the mmap module. Those are the special methods (__xyz__) implemented
> as regular ones. I thought it was best to have the functionality in
> anyway. When and if we'll have that support it will be only a matter
> of change methods names to gain compatibility with CPython's code.
> If you disagree with me let me know, I'll comment out the code or whatever.

That's fine.  Note also that you can use special method *names* in
RPython code, you just have to call them explicitly.  So for example
it's ok to have code like:

    class W_X:
       def __len__(self):
           return 42

       def get_len(self, space):
           return space.wrap(self.__len__())

Or even:

    class PurePythonBase:
        def __len__(self):
            return 42

    class W_X(PurePythonBase):
        def get_len(self, space):
            return space.wrap(self.__len__())

A bientot,


More information about the Pypy-dev mailing list