Skip to content

Commit ed7169c

Browse files
committed
Document __base__ attribute in data model reference
1 parent 9e10d94 commit ed7169c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Doc/c-api/object.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,6 @@ Object Protocol
392392
class, are considered classes. However, objects can override this by having
393393
a :attr:`~type.__bases__` attribute (which must be a tuple of base classes).
394394
395-
Another attribute, ``__base__`` corresponds to the :c:member:`~PyTypeObject.tp_base`
396-
in a type object. At the C level, Python has a single inheritance model
397-
that determines the memory layout of instances. There is a chain involving
398-
base classes that contribute to the instance layout. ``__base__`` is the base
399-
class that is involved in that chain. When such a class takes arguments in
400-
the correct order, then starting leftmost.
401-
402-
.. impl-detail::
403-
Note that behavior of the ``__base__`` attribute is dependent on the
404-
:term:`CPython` implementation.
405-
406395
407396
.. c:function:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)
408397

Doc/reference/datamodel.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,7 @@ Special attributes
11851185
single: __module__ (class attribute)
11861186
single: __dict__ (class attribute)
11871187
single: __bases__ (class attribute)
1188+
single: __base__ (class attribute)
11881189
single: __doc__ (class attribute)
11891190
single: __annotations__ (class attribute)
11901191
single: __annotate__ (class attribute)
@@ -1219,6 +1220,16 @@ Special attributes
12191220
In most cases, for a class defined as ``class X(A, B, C)``,
12201221
``X.__bases__`` will be exactly equal to ``(A, B, C)``.
12211222

1223+
* - .. attribute:: type.__base__
1224+
- The base class that determines the instance layout. This attribute
1225+
identifies the single base class in the inheritance chain that is
1226+
responsible for the memory layout of instances, corresponding to
1227+
:c:member:`~PyTypeObject.tp_base` at the C level.
1228+
1229+
.. impl-detail::
1230+
Note that behavior of the ``__base__`` attribute is dependent on the
1231+
:term:`CPython` implementation.
1232+
12221233
* - .. attribute:: type.__doc__
12231234
- The class's documentation string, or ``None`` if undefined.
12241235
Not inherited by subclasses.

0 commit comments

Comments
 (0)