@@ -116,6 +116,20 @@ Type Objects
116116 .. versionadded:: 3.12
117117
118118
119+ .. c:function:: int PyType_Unwatch(int watcher_id, PyObject *type)
120+
121+ Mark *type * as not watched. This undoes a previous call to
122+ :c:func: `PyType_Watch `. *type * must not be ``NULL ``.
123+
124+ An extension should never call this function with a *watcher_id * that was
125+ not returned to it by a previous call to :c:func: `PyType_AddWatcher `.
126+
127+ On success, this function returns ``0 ``. On failure, this function returns
128+ ``-1 `` with an exception set.
129+
130+ .. versionadded :: 3.12
131+
132+
119133.. c :type :: int (*PyType_WatchCallback)(PyObject *type)
120134
121135 Type of a type-watcher callback function.
@@ -133,6 +147,18 @@ Type Objects
133147 Type features are denoted by single bit flags.
134148
135149
150+ .. c :function :: int PyType_FastSubclass (PyTypeObject *type, int flag)
151+
152+ Return non-zero if the type object *type * sets the subclass flag *flag *.
153+ Subclass flags are denoted by
154+ :c:macro: `Py_TPFLAGS_*_SUBCLASS <Py_TPFLAGS_LONG_SUBCLASS> `.
155+ This function is used by many ``_Check `` functions for common types.
156+
157+ .. seealso ::
158+ :c:func: `PyObject_TypeCheck `, which is used as a slower alternative in
159+ ``_Check `` functions for types that don't come with subclass flags.
160+
161+
136162.. c :function :: int PyType_IS_GC (PyTypeObject *o)
137163
138164 Return true if the type object includes support for the cycle detector; this
@@ -169,12 +195,14 @@ Type Objects
169195 before initialization) and should be paired with :c:func:`PyObject_Free` in
170196 :c:member:`~PyTypeObject.tp_free`.
171197
198+
172199.. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
173200
174201 Generic handler for the :c:member: `~PyTypeObject.tp_new ` slot of a type
175202 object. Creates a new instance using the type's
176203 :c:member: `~PyTypeObject.tp_alloc ` slot and returns the resulting object.
177204
205+
178206.. c :function :: int PyType_Ready (PyTypeObject *type)
179207
180208 Finalize a type object. This should be called on all type objects to finish
@@ -191,13 +219,15 @@ Type Objects
191219 GC protocol itself by at least implementing the
192220 :c:member: `~PyTypeObject.tp_traverse ` handle.
193221
222+
194223.. c :function :: PyObject* PyType_GetName (PyTypeObject *type)
195224
196225 Return the type's name. Equivalent to getting the type's
197226 :attr: `~type.__name__ ` attribute.
198227
199228 .. versionadded :: 3.11
200229
230+
201231.. c :function :: PyObject* PyType_GetQualName (PyTypeObject *type)
202232
203233 Return the type's qualified name. Equivalent to getting the
@@ -213,13 +243,15 @@ Type Objects
213243
214244 .. versionadded :: 3.13
215245
246+
216247.. c :function :: PyObject* PyType_GetModuleName (PyTypeObject *type)
217248
218249 Return the type's module name. Equivalent to getting the
219250 :attr: `type.__module__ ` attribute.
220251
221252 .. versionadded :: 3.13
222253
254+
223255.. c :function :: void * PyType_GetSlot (PyTypeObject *type, int slot)
224256
225257 Return the function pointer stored in the given slot. If the
@@ -236,6 +268,7 @@ Type Objects
236268 :c:func: `PyType_GetSlot ` can now accept all types.
237269 Previously, it was limited to :ref: `heap types <heap-types >`.
238270
271+
239272.. c :function :: PyObject* PyType_GetModule (PyTypeObject *type)
240273
241274 Return the module object associated with the given type when the type was
@@ -255,6 +288,7 @@ Type Objects
255288
256289 .. versionadded :: 3.9
257290
291+
258292.. c :function :: void * PyType_GetModuleState (PyTypeObject *type)
259293
260294 Return the state of the module object associated with the given type.
@@ -269,6 +303,7 @@ Type Objects
269303
270304 .. versionadded :: 3.9
271305
306+
272307.. c :function :: PyObject* PyType_GetModuleByDef (PyTypeObject *type, struct PyModuleDef *def)
273308
274309 Find the first superclass whose module was created from
@@ -288,6 +323,7 @@ Type Objects
288323
289324 .. versionadded:: 3.11
290325
326+
291327.. c:function:: int PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result)
292328
293329 Find the first superclass in *type *'s :term: `method resolution order ` whose
@@ -306,6 +342,7 @@ Type Objects
306342
307343 .. versionadded :: 3.14
308344
345+
309346.. c :function :: int PyUnstable_Type_AssignVersionTag (PyTypeObject *type)
310347
311348 Attempt to assign a version tag to the given type.
@@ -316,6 +353,16 @@ Type Objects
316353 .. versionadded :: 3.12
317354
318355
356+ .. c :function :: int PyType_SUPPORTS_WEAKREFS (PyTypeObject *type)
357+
358+ Return true if instances of *type * support creating weak references, false
359+ otherwise. This function always succeeds. *type * must not be ``NULL ``.
360+
361+ .. seealso ::
362+ * :ref: `weakrefobjects `
363+ * :py:mod: `weakref `
364+
365+
319366Creating Heap-Allocated Types
320367.............................
321368
@@ -364,6 +411,7 @@ The following functions and structs are used to create
364411
365412 .. versionadded:: 3.12
366413
414+
367415.. c:function:: PyObject* PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
368416
369417 Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases) ``.
@@ -390,6 +438,7 @@ The following functions and structs are used to create
390438 Creating classes whose metaclass overrides
391439 :c:member: `~PyTypeObject.tp_new ` is no longer allowed.
392440
441+
393442.. c :function :: PyObject* PyType_FromSpecWithBases (PyType_Spec *spec, PyObject *bases)
394443
395444 Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases) ``.
@@ -411,6 +460,7 @@ The following functions and structs are used to create
411460 Creating classes whose metaclass overrides
412461 :c:member: `~PyTypeObject.tp_new ` is no longer allowed.
413462
463+
414464.. c :function :: PyObject* PyType_FromSpec (PyType_Spec *spec)
415465
416466 Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL) ``.
@@ -431,6 +481,7 @@ The following functions and structs are used to create
431481 Creating classes whose metaclass overrides
432482 :c:member: `~PyTypeObject.tp_new ` is no longer allowed.
433483
484+
434485.. c :function :: int PyType_Freeze (PyTypeObject *type)
435486
436487 Make a type immutable: set the :c:macro: `Py_TPFLAGS_IMMUTABLETYPE ` flag.
@@ -602,6 +653,7 @@ The following functions and structs are used to create
602653 * :c:data:`Py_tp_token` (for clarity, prefer :c:data: `Py_TP_USE_SPEC `
603654 rather than ``NULL ``)
604655
656+
605657.. c:macro:: Py_tp_token
606658
607659 A :c:member:`~PyType_Slot.slot` that records a static memory layout ID
0 commit comments