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>
This commit is contained in:
Mark Shannon 2022-08-09 14:26:37 +01:00 committed by GitHub
parent eb81c1aea1
commit 8d37c62c2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 13 deletions

View file

@ -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*,