sandbox/morph / Doc / c-api / object.rst

Full commit

Object Protocol


If o1 and o2 are the same object, :c:func:`PyObject_RichCompareBool` will always return 1 for :const:`Py_EQ` and 0 for :const:`Py_NE`.

Subclass determination is done in a fairly straightforward way, but includes a wrinkle that implementors of extensions to the class system may want to be aware of. If :class:`A` and :class:`B` are class objects, :class:`B` is a subclass of :class:`A` if it inherits from :class:`A` either directly or indirectly. If either is not a class object, a more general mechanism is used to determine the class relationship of the two objects. When testing if B is a subclass of A, if A is B, :c:func:`PyObject_IsSubclass` returns true. If A and B are different objects, B's :attr:`__bases__` attribute is searched in a depth-first fashion for A --- the presence of the :attr:`__bases__` attribute is considered sufficient for this determination.