You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Doc/c-api/memory.rst
+10-6Lines changed: 10 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -102,12 +102,16 @@ All allocating functions belong to one of three different "domains" (see also
102
102
strategies and are optimized for different purposes. The specific details on
103
103
how every domain allocates memory or what internal functions each domain calls
104
104
is considered an implementation detail, but for debugging purposes a simplified
105
-
table can be found at :ref:`here <default-memory-allocators>`. There is no hard
106
-
requirement to use the memory returned by the allocation functions belonging to
107
-
a given domain for only the purposes hinted by that domain (although this is the
108
-
recommended practice). For example, one could use the memory returned by
109
-
:c:func:`PyMem_RawMalloc` for allocating Python objects or the memory returned
110
-
by :c:func:`PyObject_Malloc` for allocating memory for buffers.
105
+
table can be found at :ref:`here <default-memory-allocators>`. In the default build,
106
+
there is no hard requirement to use the memory returned by the allocation functions
107
+
belonging to a given domain for only the purposes hinted by that domain.
108
+
(although this is the recommended practice). For example, one could use the memory
109
+
returned by :c:func:`PyMem_RawMalloc` for allocating Python objects or the memory
110
+
returned by :c:func:`PyObject_Malloc` for allocating memory for buffers.
111
+
However, in the free-threaded build, Python objects must be allocated through :c:func:`PyObject_Malloc`.
112
+
Non-Python objects must not be allocated this function, for example,
113
+
it is currently acceptable to allocate buffers(non-Python objects) through :c:func:`PyObject_Malloc`;
114
+
that will no longer be allowed and buffers should instead be allocated through :c:func:`PyMem_Malloc`, :c:func:`PyMem_RawMalloc`, or :c:func:`malloc`..
0 commit comments