Skip to content

Commit f82578a

Browse files
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. (cherry picked from commit 32181be) Co-authored-by: Guanzhong Chen <[email protected]>
1 parent d81a204 commit f82578a

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

@@ -393,19 +406,6 @@ since it is impossible to detect the termination of alien threads.
393406
property instead.
394407

395408

396-
.. impl-detail::
397-
398-
In CPython, due to the :term:`Global Interpreter Lock
399-
<global interpreter lock>`, only one thread
400-
can execute Python code at once (even though certain performance-oriented
401-
libraries might overcome this limitation).
402-
If you want your application to make better use of the computational
403-
resources of multi-core machines, you are advised to use
404-
:mod:`multiprocessing` or :class:`concurrent.futures.ProcessPoolExecutor`.
405-
However, threading is still an appropriate model if you want to run
406-
multiple I/O-bound tasks simultaneously.
407-
408-
409409
.. _lock-objects:
410410

411411
Lock Objects

0 commit comments

Comments
 (0)