Skip to content

Commit 86efce6

Browse files
committed
gh-119802: Update memory management docs for free-threaded build
1 parent 8e99495 commit 86efce6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Doc/c-api/memory.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ All allocating functions belong to one of three different "domains" (see also
102102
strategies and are optimized for different purposes. The specific details on
103103
how every domain allocates memory or what internal functions each domain calls
104104
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`..
111115

112116
The three allocation domains are:
113117

0 commit comments

Comments
 (0)