@@ -110,12 +110,12 @@ The three allocation domains are:
110
110
111
111
* Raw domain: intended for allocating memory for general-purpose memory
112
112
buffers where the allocation *must * go to the system allocator or where the
113
- allocator can operate without the :term: `GIL `. The memory is requested directly
114
- from the system. See :ref: `Raw Memory Interface <raw-memoryinterface >`.
113
+ allocator can operate without an :term: `attached thread state `. The memory
114
+ is requested directly from the system. See :ref: `Raw Memory Interface <raw-memoryinterface >`.
115
115
116
116
* "Mem" domain: intended for allocating memory for Python buffers and
117
117
general-purpose memory buffers where the allocation must be performed with
118
- the :term: `GIL ` held . The memory is taken from the Python private heap.
118
+ an :term: `attached thread state ` . The memory is taken from the Python private heap.
119
119
See :ref: `Memory Interface <memoryinterface >`.
120
120
121
121
* Object domain: intended for allocating memory for Python objects. The
@@ -139,8 +139,8 @@ Raw Memory Interface
139
139
====================
140
140
141
141
The following function sets are wrappers to the system allocator. These
142
- functions are thread-safe, the :term: `GIL <global interpreter lock> ` does not
143
- need to be held .
142
+ functions are thread-safe, so a :term: `thread state ` does not
143
+ need to be :term: ` attached <attached thread state> ` .
144
144
145
145
The :ref: `default raw memory allocator <default-memory-allocators >` uses
146
146
the following functions: :c:func: `malloc `, :c:func: `calloc `, :c:func: `realloc `
@@ -213,8 +213,7 @@ The :ref:`default memory allocator <default-memory-allocators>` uses the
213
213
214
214
.. warning ::
215
215
216
- The :term: `GIL <global interpreter lock> ` must be held when using these
217
- functions.
216
+ There must be an :term: `attached thread state ` when using these functions.
218
217
219
218
.. versionchanged :: 3.6
220
219
@@ -327,8 +326,7 @@ The :ref:`default object allocator <default-memory-allocators>` uses the
327
326
328
327
.. warning ::
329
328
330
- The :term: `GIL <global interpreter lock> ` must be held when using these
331
- functions.
329
+ There must be an :term: `attached thread state ` when using these functions.
332
330
333
331
.. c :function :: void * PyObject_Malloc (size_t n)
334
332
@@ -485,12 +483,12 @@ Customize Memory Allocators
485
483
zero bytes.
486
484
487
485
For the :c:macro: `PYMEM_DOMAIN_RAW ` domain, the allocator must be
488
- thread-safe: the :term: `GIL <global interpreter lock> ` is not held when the
489
- allocator is called.
486
+ thread-safe: a :term: `thread state ` is not :term: ` attached <attached thread state> `
487
+ when the allocator is called.
490
488
491
489
For the remaining domains, the allocator must also be thread-safe:
492
490
the allocator may be called in different interpreters that do not
493
- share a `` GIL ` `.
491
+ share a :term: ` GIL `.
494
492
495
493
If the new allocator is not a hook (does not call the previous allocator),
496
494
the :c:func:`PyMem_SetupDebugHooks` function must be called to reinstall the
@@ -507,8 +505,8 @@ Customize Memory Allocators
507
505
:c:func:`Py_InitializeFromConfig` to install a custom memory
508
506
allocator. There are no restrictions over the installed allocator
509
507
other than the ones imposed by the domain (for instance, the Raw
510
- Domain allows the allocator to be called without the GIL held). See
511
- :ref:`the section on allocator domains <allocator-domains>` for more
508
+ Domain allows the allocator to be called without an :term: ` attached thread state `).
509
+ See :ref:`the section on allocator domains <allocator-domains>` for more
512
510
information.
513
511
514
512
* If called after Python has finish initializing (after
@@ -555,7 +553,7 @@ Runtime checks:
555
553
called on a memory block allocated by :c:func:`PyMem_Malloc`.
556
554
- Detect write before the start of the buffer (buffer underflow).
557
555
- Detect write after the end of the buffer (buffer overflow).
558
- - Check that the :term:`GIL <global interpreter lock>` is held when
556
+ - Check that there is an :term:`attached thread state` when
559
557
allocator functions of :c:macro:`PYMEM_DOMAIN_OBJ` (ex:
560
558
:c:func: `PyObject_Malloc `) and :c:macro:`PYMEM_DOMAIN_MEM` (ex:
561
559
:c:func: `PyMem_Malloc `) domains are called.
@@ -620,8 +618,8 @@ PYMEM_CLEANBYTE (meaning uninitialized memory is getting used).
620
618
The :c:func:`PyMem_SetupDebugHooks` function now also works on Python
621
619
compiled in release mode. On error, the debug hooks now use
622
620
:mod:`tracemalloc` to get the traceback where a memory block was allocated.
623
- The debug hooks now also check if the GIL is held when functions of
624
- :c:macro:`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are
621
+ The debug hooks now also check if there is an :term:`attached thread state` when
622
+ functions of :c:macro:`PYMEM_DOMAIN_OBJ` and :c:macro:`PYMEM_DOMAIN_MEM` domains are
625
623
called.
626
624
627
625
.. versionchanged:: 3.8
0 commit comments