[pypy-dev] Builtin types

Christian Tismer tismer at tismer.com
Fri Jan 24 01:43:26 CET 2003

Scott Fenton wrote:
> Hello all. While trying to mix up some more stuff for
> __builtin__, I came up with an interesting problem.
> The solution I found for classmethod (using google on
> c.l.python, since I couldn't figure it out myself) 
> requires that classes that use it
> must derive from object.

No, this is not true.
classmethod works for every kind of class,
may it be a newstyle class, triggered by
- deriving from object
- using __slots__
- deriving from a builtin type or a descendant
- did I forget something?
or a "classic" class, it always works.
For reference, see

> That made me wonder, could
> we just automatically derive everything from object
> in Minimal? The big problem with doing this in CPython,
> as I understand it, is extensions that need to be
> converted, but we don't have that problem here, obviously.
> So would it be alright if I went ahead and used this code
> as if everything derived from object?

No, sorry. object is just a special case for deriving a
new-style class, see above.
They can also be created by deriving from builtin types,
or by using __slots__.

Furthermore, I'm going to propose an extension to the new
class system (at least for the MiniPy prototype) that goes
a bit further:
- __slots__ should get the ability to denote the type of
   a slot to be generated, especially ctypes types
- it should be possible to derive a class from nothing,
   not even from object or classic, but I'd like to describe
   a plain C structure by classes.

The latter will allow to define the object class and all
builtin types with the same machinery.

But please go ahead with your __builtins__ as it seems to
fit. We can fix such stuff later.
If you want to be perfect, try to define it for any class.

cheers & thanks! -- chris

More information about the Pypy-dev mailing list