summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/object.rst
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2023-05-04 07:56:53 (GMT)
committerGitHub <noreply@github.com>2023-05-04 07:56:53 (GMT)
commitcd9a56c2b0e14f56f2e83dd4db43c5c69a74b232 (patch)
treeff971ebbdb11701bab003d743a6d5b928c35184f /Doc/c-api/object.rst
parent35d273825abc319d0ecbd69110e847f6040d0cd7 (diff)
downloadcpython-cd9a56c2b0e14f56f2e83dd4db43c5c69a74b232.zip
cpython-cd9a56c2b0e14f56f2e83dd4db43c5c69a74b232.tar.gz
cpython-cd9a56c2b0e14f56f2e83dd4db43c5c69a74b232.tar.bz2
gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511)
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Doc/c-api/object.rst')
-rw-r--r--Doc/c-api/object.rst39
1 files changed, 39 insertions, 0 deletions
diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst
index 0a12bb9..a0c3194 100644
--- a/Doc/c-api/object.rst
+++ b/Doc/c-api/object.rst
@@ -395,3 +395,42 @@ Object Protocol
returns ``NULL`` if the object cannot be iterated.
.. versionadded:: 3.10
+
+.. c:function:: void *PyObject_GetTypeData(PyObject *o, PyTypeObject *cls)
+
+ Get a pointer to subclass-specific data reserved for *cls*.
+
+ The object *o* must be an instance of *cls*, and *cls* must have been
+ created using negative :c:member:`PyType_Spec.basicsize`.
+ Python does not check this.
+
+ On error, set an exception and return ``NULL``.
+
+ .. versionadded:: 3.12
+
+.. c:function:: Py_ssize_t PyType_GetTypeDataSize(PyTypeObject *cls)
+
+ Return the size of the instance memory space reserved for *cls*, i.e. the size of the
+ memory :c:func:`PyObject_GetTypeData` returns.
+
+ This may be larger than requested using :c:member:`-PyType_Spec.basicsize <PyType_Spec.basicsize>`;
+ it is safe to use this larger size (e.g. with :c:func:`!memset`).
+
+ The type *cls* **must** have been created using
+ negative :c:member:`PyType_Spec.basicsize`.
+ Python does not check this.
+
+ On error, set an exception and return a negative value.
+
+ .. versionadded:: 3.12
+
+.. c:function:: void *PyObject_GetItemData(PyObject *o)
+
+ Get a pointer to per-item data for a class with
+ :const:`Py_TPFLAGS_ITEMS_AT_END`.
+
+ On error, set an exception and return ``NULL``.
+ :py:exc:`TypeError` is raised if *o* does not have
+ :const:`Py_TPFLAGS_ITEMS_AT_END` set.
+
+ .. versionadded:: 3.12