Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e7d711

Browse files
committed
Merged revisions 87792 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ........ r87792 | antoine.pitrou | 2011-01-06 17:31:28 +0100 (jeu., 06 janv. 2011) | 3 lines Elaborate about the GIL. ........
1 parent 818581c commit 6e7d711

2 files changed

Lines changed: 34 additions & 13 deletions

File tree

Doc/glossary.rst

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ Glossary
9999
See :pep:`343`.
100100

101101
CPython
102-
The canonical implementation of the Python programming language. The
103-
term "CPython" is used in contexts when necessary to distinguish this
104-
implementation from others such as Jython or IronPython.
102+
The canonical implementation of the Python programming language, as
103+
distributed on `python.org <http://python.org>`_. The term "CPython"
104+
is used when necessary to distinguish this implementation from others
105+
such as Jython or IronPython.
105106

106107
decorator
107108
A function returning another function, usually applied as a function
@@ -258,16 +259,25 @@ Glossary
258259
See :term:`global interpreter lock`.
259260

260261
global interpreter lock
261-
The lock used by Python threads to assure that only one thread
262-
executes in the :term:`CPython` :term:`virtual machine` at a time.
263-
This simplifies the CPython implementation by assuring that no two
264-
processes can access the same memory at the same time. Locking the
265-
entire interpreter makes it easier for the interpreter to be
266-
multi-threaded, at the expense of much of the parallelism afforded by
267-
multi-processor machines. Efforts have been made in the past to
268-
create a "free-threaded" interpreter (one which locks shared data at a
269-
much finer granularity), but so far none have been successful because
270-
performance suffered in the common single-processor case.
262+
The mechanism used by the :term:`CPython` interpreter to assure that
263+
only one thread executes Python :term:`bytecode` at a time.
264+
This simplifies the CPython implementation by making the object model
265+
(including critical built-in types such as :class:`dict`) implicitly
266+
safe against concurrent access. Locking the entire interpreter
267+
makes it easier for the interpreter to be multi-threaded, at the
268+
expense of much of the parallelism afforded by multi-processor
269+
machines.
270+
271+
However, some extension modules, either standard or third-party,
272+
are designed so as to release the GIL when doing computationally-intensive
273+
tasks such as compression or hashing. Also, the GIL is always released
274+
when doing I/O.
275+
276+
Past efforts to create a "free-threaded" interpreter (one which locks
277+
shared data at a much finer granularity) have not been successful
278+
because performance suffered in the common single-processor case. It
279+
is believed that overcoming this performance issue would make the
280+
implementation much more complicated and therefore costlier to maintain.
271281

272282
hashable
273283
An object is *hashable* if it has a hash value which never changes during

Doc/library/threading.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ The :mod:`dummy_threading` module is provided for situations where
1717
methods and functions in this module in the Python 2.x series are still
1818
supported by this module.
1919

20+
.. impl-detail::
21+
22+
Due to the :term:`Global Interpreter Lock`, in CPython only one thread
23+
can execute Python code at once (even though certain performance-oriented
24+
libraries might overcome this limitation).
25+
If you want your application to make better of use of the computational
26+
resources of multi-core machines, you are advised to use
27+
:mod:`multiprocessing`. However, threading is still an appropriate model
28+
if you want to run multiple I/O-bound tasks simultaneously.
29+
30+
2031
This module defines the following functions and objects:
2132

2233

0 commit comments

Comments
 (0)