Object Protocol¶
Note
If o1 and o2 are the same object, :cfunc:`PyObject_RichCompareBool`
will always return 1
for Py_EQ
and 0
for 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 A
and B
are class objects, B
is a subclass of
A
if it inherits from 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, :cfunc:`PyObject_IsSubclass` returns true. If A and B
are different objects, B’s __bases__
attribute is searched in a
depth-first fashion for A — the presence of the __bases__
attribute
is considered sufficient for this determination.