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? Thanks, Dan
Hi, 2010/1/7 Dan Roberts <ademan555@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 pypy.objspace.std.register_all() -- Amaury Forgeot d'Arc
participants (2)
-
Amaury Forgeot d'Arc
-
Dan Roberts