Re: Re[2]: Re: class proposal

Greg Ewing <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
Lenard Lindstrom <[email protected]>:

> The tp_base and tp_bases slot may be defined for PyTypeObject but
> does the interpreter actually use then directly, let alone know
> about them? Or is it there as a convenience for the PyType_Type slot
> functions?  Could I define a PyTypeObject instance that does not
> actually use these slots?  I admit I am not clear on how new-style
> class types inherit through tp_base and tp_bases.

Only single inheritance exists at the C level, and it's implemented by
copying down function pointers from the type object pointed to by
tp_base (this happens when you initialise the type by calling
PyType_Ready).

As far as I know, tp_bases is only used when doing a Python attribute
lookup, and that's done by the default function installed in the
tp_getattr slot of the type object.

It would be possible to create a type object with a different
tp_getattr that implemented prototype behaviour instead of
class/instance behaviour, or a different system for Python-level
inheritance that didn't use tp_bases at all, or anything else you
wanted.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
[email protected]	   +--------------------------------------+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.