Skip to content

Commit 32181be

Browse files
authored
bpo-43293: Doc: move note about GIL to top of threading module (GH-24622)
The note about the GIL was buried pretty deep in the threading documentation, and this made it hard for first time users to discover why their attempts at using threading to parallelizing their application did not work. In this commit, the note is moved to the top of the module documention for visibility.
1 parent 1f43340 commit 32181be

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Doc/library/threading.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ level :mod:`_thread` module. See also the :mod:`queue` module.
2121
supported by this module.
2222

2323

24+
.. impl-detail::
25+
26+
In CPython, due to the :term:`Global Interpreter Lock
27+
<global interpreter lock>`, only one thread
28+
can execute Python code at once (even though certain performance-oriented
29+
libraries might overcome this limitation).
30+
If you want your application to make better use of the computational
31+
resources of multi-core machines, you are advised to use
32+
:mod:`multiprocessing` or :class:`concurrent.futures.ProcessPoolExecutor`.
33+
However, threading is still an appropriate model if you want to run
34+
multiple I/O-bound tasks simultaneously.
35+
36+
2437
This module defines the following functions:
2538

2639

@@ -424,19 +437,6 @@ since it is impossible to detect the termination of alien threads.
424437
property instead.
425438

426439

427-
.. impl-detail::
428-
429-
In CPython, due to the :term:`Global Interpreter Lock
430-
<global interpreter lock>`, only one thread
431-
can execute Python code at once (even though certain performance-oriented
432-
libraries might overcome this limitation).
433-
If you want your application to make better use of the computational
434-
resources of multi-core machines, you are advised to use
435-
:mod:`multiprocessing` or :class:`concurrent.futures.ProcessPoolExecutor`.
436-
However, threading is still an appropriate model if you want to run
437-
multiple I/O-bound tasks simultaneously.
438-
439-
440440
.. _lock-objects:
441441

442442
Lock Objects

0 commit comments

Comments
 (0)