Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63aeb71

Browse files
committed
Issue #9307: document the various Py_TPFLAGS_*_SUBCLASS flags. Patch by Yury V. Zaytsev.
2 parents b1e5844 + f9f54a2 commit 63aeb71

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Doc/c-api/typeobj.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,24 @@ type objects) *must* have the :attr:`ob_size` field.
464464
:const:`Py_TPFLAGS_HAVE_VERSION_TAG`.
465465

466466

467+
.. data:: Py_TPFLAGS_LONG_SUBCLASS
468+
.. data:: Py_TPFLAGS_LIST_SUBCLASS
469+
.. data:: Py_TPFLAGS_TUPLE_SUBCLASS
470+
.. data:: Py_TPFLAGS_BYTES_SUBCLASS
471+
.. data:: Py_TPFLAGS_UNICODE_SUBCLASS
472+
.. data:: Py_TPFLAGS_DICT_SUBCLASS
473+
.. data:: Py_TPFLAGS_BASE_EXC_SUBCLASS
474+
.. data:: Py_TPFLAGS_TYPE_SUBCLASS
475+
476+
These flags are used by functions such as
477+
:c:func:`PyLong_Check` to quickly determine if a type is a subclass
478+
of a built-in type; such specific checks are faster than a generic
479+
check, like :c:func:`PyObject_IsInstance`. Custom types that inherit
480+
from built-ins should have their :c:member:`~PyTypeObject.tp_flags`
481+
set appropriately, or the code that interacts with such types
482+
will behave differently depending on what kind of check is used.
483+
484+
467485
.. data:: Py_TPFLAGS_HAVE_FINALIZE
468486

469487
This bit is set when the :c:member:`~PyTypeObject.tp_finalize` slot is present in the

0 commit comments

Comments
 (0)