File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,18 @@ Type Objects
133133 Type features are denoted by single bit flags.
134134
135135
136+ .. c :function :: int PyType_FastSubclass (PyTypeObject *type, int flag)
137+
138+ Return non-zero if the type object *type * sets the subclass flag *flag *.
139+ Subclass flags are denoted by
140+ :c:macro: `Py_TPFLAGS_*_SUBCLASS <Py_TPFLAGS_LONG_SUBCLASS> `.
141+ This function is used by many ``_Check `` functions for common types.
142+
143+ .. seealso ::
144+ :c:func: `PyObject_TypeCheck `, which is used as a slower alternative in
145+ ``_Check `` functions for types that don't come with subclass flags.
146+
147+
136148.. c :function :: int PyType_IS_GC (PyTypeObject *o)
137149
138150 Return true if the type object includes support for the cycle detector; this
Original file line number Diff line number Diff line change @@ -1248,8 +1248,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
12481248 .. c :macro :: Py_TPFLAGS_BASE_EXC_SUBCLASS
12491249 .. c :macro :: Py_TPFLAGS_TYPE_SUBCLASS
12501250
1251- These flags are used by functions such as
1252- :c:func: ` PyLong_Check ` to quickly determine if a type is a subclass
1251+ Functions such as :c:func: ` PyLong_Check ` will call :c:func: ` PyType_FastSubclass `
1252+ with one of these flags to quickly determine if a type is a subclass
12531253 of a built-in type; such specific checks are faster than a generic
12541254 check, like :c:func: `PyObject_IsInstance `. Custom types that inherit
12551255 from built-ins should have their :c:member: `~PyTypeObject.tp_flags `
You can’t perform that action at this time.
0 commit comments