summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/object.rst
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-08-09 13:26:37 (GMT)
committerGitHub <noreply@github.com>2022-08-09 13:26:37 (GMT)
commit8d37c62c2a2579ae7839ecaf8351e862f2ecc9bb (patch)
tree17dfb0a52cdeb4da979d2b43fbe5c4beee832a4f /Doc/c-api/object.rst
parenteb81c1aea16914347919745e843c982ed831a9fb (diff)
downloadcpython-8d37c62c2a2579ae7839ecaf8351e862f2ecc9bb.zip
cpython-8d37c62c2a2579ae7839ecaf8351e862f2ecc9bb.tar.gz
cpython-8d37c62c2a2579ae7839ecaf8351e862f2ecc9bb.tar.bz2
GH-92678: Document that you shouldn't be doing your own dictionary offset calculations. (GH-95598)
Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Diffstat (limited to 'Doc/c-api/object.rst')
-rw-r--r--Doc/c-api/object.rst18
1 files changed, 18 insertions, 0 deletions
diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst
index 07a625b..fb03366 100644
--- a/Doc/c-api/object.rst
+++ b/Doc/c-api/object.rst
@@ -126,6 +126,14 @@ Object Protocol
A generic implementation for the getter of a ``__dict__`` descriptor. It
creates the dictionary if necessary.
+ This function may also be called to get the :py:attr:`~object.__dict__`
+ of the object *o*. Pass ``NULL`` for *context* when calling it.
+ Since this function may need to allocate memory for the
+ dictionary, it may be more efficient to call :c:func:`PyObject_GetAttr`
+ when accessing an attribute on the object.
+
+ On failure, returns ``NULL`` with an exception set.
+
.. versionadded:: 3.3
@@ -137,6 +145,16 @@ Object Protocol
.. versionadded:: 3.3
+.. c:function:: PyObject** _PyObject_GetDictPtr(PyObject *obj)
+
+ Return a pointer to :py:attr:`~object.__dict__` of the object *obj*.
+ If there is no ``__dict__``, return ``NULL`` without setting an exception.
+
+ This function may need to allocate memory for the
+ dictionary, so it may be more efficient to call :c:func:`PyObject_GetAttr`
+ when accessing an attribute on the object.
+
+
.. c:function:: PyObject* PyObject_RichCompare(PyObject *o1, PyObject *o2, int opid)
Compare the values of *o1* and *o2* using the operation specified by *opid*,