]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Docs: Fix and improve the `PyUnstable_Object_EnableDeferredRefcount` documentation...
authorPeter Bierma <zintensitydev@gmail.com>
Sun, 13 Jul 2025 06:46:13 +0000 (02:46 -0400)
committerGitHub <noreply@github.com>
Sun, 13 Jul 2025 06:46:13 +0000 (02:46 -0400)
Doc/c-api/object.rst

index 21fa1491b33d869d703c1ea2b9a3f1e140712563..55f0d0f9fb7ff86472575c5ad13220728daf1384 100644 (file)
@@ -611,12 +611,13 @@ Object Protocol
    if supported by the runtime.  In the :term:`free-threaded <free threading>` build,
    this allows the interpreter to avoid reference count adjustments to *obj*,
    which may improve multi-threaded performance.  The tradeoff is
-   that *obj* will only be deallocated by the tracing garbage collector.
+   that *obj* will only be deallocated by the tracing garbage collector, and
+   not when the interpreter no longer has any references to it.
 
-   This function returns ``1`` if deferred reference counting is enabled on *obj*
-   (including when it was enabled before the call),
+   This function returns ``1`` if deferred reference counting is enabled on *obj*,
    and ``0`` if deferred reference counting is not supported or if the hint was
-   ignored by the runtime. This function is thread-safe, and cannot fail.
+   ignored by the interpreter, such as when deferred reference counting is already
+   enabled on *obj*. This function is thread-safe, and cannot fail.
 
    This function does nothing on builds with the :term:`GIL` enabled, which do
    not support deferred reference counting. This also does nothing if *obj* is not
@@ -624,7 +625,8 @@ Object Protocol
    :c:func:`PyObject_GC_IsTracked`).
 
    This function is intended to be used soon after *obj* is created,
-   by the code that creates it.
+   by the code that creates it, such as in the object's :c:member:`~PyTypeObject.tp_new`
+   slot.
 
    .. versionadded:: 3.14