[pypy-dev] Applevel types

Amaury Forgeot d'Arc amauryfa at gmail.com
Thu Jan 7 09:18:29 CET 2010


2010/1/7 Dan Roberts <ademan555 at gmail.com>:
>    I want to make multiple interpreter-level types appear as a single
> application-level type.  Armin got me started in the right direction,
> pointing out pypy/objspace/std/{small,}int{type,object}.py to me.  This
> made it clear that sharing a typedef will accomplish this, however in
> the case of integer objects, only __new__ is registered with the
> typedef.  How are other methods registered for object instances?  I
> assumed that only methods provided to TypeDef would be visible at the
> application-level on instances, however this must not be the case, are
> any methods on the interpreter-level classes automatically wrapped?  Can
> anyone provide more complex examples or explain exactly how the int
> functionality works?

I think this is because int objects have no methods outside the special slots
__float__ __add__ __repr__... which are implemented as MultiMethods:
float__Int in intobject.py, for example.

The magic that converts these functions to type methods is in

Amaury Forgeot d'Arc

More information about the Pypy-dev mailing list