FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-141004: Document `PyType_FastSubclass` by StanFromIreland · Pull Request #141313 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 12 additions & 0 deletions Doc/c-api/type.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ Type Objects
Type features are denoted by single bit flags.


.. c:function:: int PyType_FastSubclass(PyTypeObject *type, int flag)

Return non-zero if the type object *type* sets the subclass flag *flag*.
Subclass flags are denoted by
:c:macro:`Py_TPFLAGS_*_SUBCLASS <Py_TPFLAGS_LONG_SUBCLASS>`.
Comment thread
StanFromIreland marked this conversation as resolved.
This function is used by many ``_Check`` functions for common types.

.. seealso::
:c:func:`PyObject_TypeCheck`, which is used as a slower alternative in
``_Check`` functions for types that don't come with subclass flags.


.. c:function:: int PyType_IS_GC(PyTypeObject *o)

Return true if the type object includes support for the cycle detector; this
Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/typeobj.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1351,8 +1351,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
.. c:macro:: Py_TPFLAGS_BASE_EXC_SUBCLASS
.. c:macro:: Py_TPFLAGS_TYPE_SUBCLASS

These flags are used by functions such as
:c:func:`PyLong_Check` to quickly determine if a type is a subclass
Functions such as :c:func:`PyLong_Check` will call :c:func:`PyType_FastSubclass`
with one of these flags to quickly determine if a type is a subclass
of a built-in type; such specific checks are faster than a generic
check, like :c:func:`PyObject_IsInstance`. Custom types that inherit
from built-ins should have their :c:member:`~PyTypeObject.tp_flags`
Expand Down
Loading

Back | FazBrowse Home | New Git URL