[pypy-dev] Can someone explain __extend__?

Maciej Fijalkowski fijall at gmail.com
Fri Apr 17 19:00:27 CEST 2015


I suggest IRC for such questions

Generally __extend__ extends an existing class (so just adds methods).
__extend__(pairtype(...)) is an implementation of double-dispatch
multimethods

On Fri, Apr 17, 2015 at 6:58 PM, VanL <van.lindberg at gmail.com> wrote:
> I am having some trouble wrapping my head around it. Reading through
> rpython/tools/pairtype.py, it looks like it could be one or more of a number
> of things:
>
> - An implementation of javascript-style prototypes. (The similarity: you
> don't subclass an object in js - you use the base object as a prototype and
> extend it with new functionality)
>
> - A way to do specialization and automatic dispatching on types so that a+b
> works (both "a" and "b" know what they are, and whether they are compatible
> with each other in an __add__/__radd__ sense, and what type should be
> returned as a result of that call)
>
> - Sort of a first draft of ABCs, allowing composition and type buildup
> without explicit inheritance (roughly, __extend__ is similar to
> ABC.register)
>
> - Other?
>
> Thanks,
> Van
>
>
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> https://mail.python.org/mailman/listinfo/pypy-dev
>


More information about the pypy-dev mailing list