summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorJurica Bradarić <jbradaric@users.noreply.github.com>2023-05-02 11:38:46 (GMT)
committerGitHub <noreply@github.com>2023-05-02 11:38:46 (GMT)
commit87223f32aba872cfebde6fbe38673799eb79f248 (patch)
treec75eeb511663531c2a822e3814877c1bd4fc62c4 /Doc/c-api
parentf6314b92dcfc8ca6ff3fd150814f85448db69165 (diff)
downloadcpython-87223f32aba872cfebde6fbe38673799eb79f248.zip
cpython-87223f32aba872cfebde6fbe38673799eb79f248.tar.gz
cpython-87223f32aba872cfebde6fbe38673799eb79f248.tar.bz2
gh-103743: Add PyUnstable_Object_GC_NewWithExtraData (GH-103744)
Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/gcsupport.rst21
1 files changed, 20 insertions, 1 deletions
diff --git a/Doc/c-api/gcsupport.rst b/Doc/c-api/gcsupport.rst
index cb5d64a..c3260a2 100644
--- a/Doc/c-api/gcsupport.rst
+++ b/Doc/c-api/gcsupport.rst
@@ -59,12 +59,31 @@ rules:
Analogous to :c:func:`PyObject_New` but for container objects with the
:const:`Py_TPFLAGS_HAVE_GC` flag set.
-
.. c:function:: TYPE* PyObject_GC_NewVar(TYPE, PyTypeObject *type, Py_ssize_t size)
Analogous to :c:func:`PyObject_NewVar` but for container objects with the
:const:`Py_TPFLAGS_HAVE_GC` flag set.
+.. c:function:: PyObject* PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *type, size_t extra_size)
+
+ Analogous to :c:func:`PyObject_GC_New` but allocates *extra_size*
+ bytes at the end of the object (at offset
+ :c:member:`~PyTypeObject.tp_basicsize`).
+ The allocated memory is initialized to zeros,
+ except for the :c:type:`Python object header <PyObject>`.
+
+ The extra data will be deallocated with the object, but otherwise it is
+ not managed by Python.
+
+ .. warning::
+ The function is marked as unstable because the final mechanism
+ for reserving extra data after an instance is not yet decided.
+ For allocating a variable number of fields, prefer using
+ :c:type:`PyVarObject` and :c:member:`~PyTypeObject.tp_itemsize`
+ instead.
+
+ .. versionadded:: 3.12
+
.. c:function:: TYPE* PyObject_GC_Resize(TYPE, PyVarObject *op, Py_ssize_t newsize)