Skip to content

Commit c828b72

Browse files
committed
Strongly suggest Py_SIZE & Py_SET_SIZE
1 parent e3ad8e7 commit c828b72

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Doc/c-api/typeobj.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ PyVarObject Slots
537537
initialized to zero. For :ref:`dynamically allocated type objects
538538
<heap-types>`, this field has a special internal meaning.
539539

540+
This field should be accessed using the :c:func:`Py_SIZE()` and
541+
:c:func:`Py_SET_SIZE()` macros.
542+
540543
**Inheritance:**
541544

542545
This field is not inherited by subtypes.
@@ -611,6 +614,11 @@ and :c:data:`PyType_Type` effectively act as defaults.)
611614
way; the underlying storage and its size should be acessed using
612615
:c:func:`PyLong_Export`.
613616

617+
.. note::
618+
619+
The :c:member:`~PyVarObject.ob_size` field should be accessed using
620+
the :c:func:`Py_SIZE()` and :c:func:`Py_SET_SIZE()` macros.
621+
614622
Also, the presence of an :c:member:`~PyVarObject.ob_size` field in the
615623
instance layout doesn't mean that the instance structure is variable-length.
616624
For example, the :py:type:`list` type has fixed-length instances, yet those

0 commit comments

Comments
 (0)