mirror of https://github.com/python/cpython
Merged revisions 87792 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87792 | antoine.pitrou | 2011-01-06 17:31:28 +0100 (jeu., 06 janv. 2011) | 3 lines Elaborate about the GIL. ........
This commit is contained in:
parent
5047225bac
commit
9f41bb325b
|
@ -106,9 +106,10 @@ Glossary
|
||||||
See :pep:`343`.
|
See :pep:`343`.
|
||||||
|
|
||||||
CPython
|
CPython
|
||||||
The canonical implementation of the Python programming language. The
|
The canonical implementation of the Python programming language, as
|
||||||
term "CPython" is used in contexts when necessary to distinguish this
|
distributed on `python.org <http://python.org>`_. The term "CPython"
|
||||||
implementation from others such as Jython or IronPython.
|
is used when necessary to distinguish this implementation from others
|
||||||
|
such as Jython or IronPython.
|
||||||
|
|
||||||
decorator
|
decorator
|
||||||
A function returning another function, usually applied as a function
|
A function returning another function, usually applied as a function
|
||||||
|
@ -253,16 +254,25 @@ Glossary
|
||||||
See :term:`global interpreter lock`.
|
See :term:`global interpreter lock`.
|
||||||
|
|
||||||
global interpreter lock
|
global interpreter lock
|
||||||
The lock used by Python threads to assure that only one thread
|
The mechanism used by the :term:`CPython` interpreter to assure that
|
||||||
executes in the :term:`CPython` :term:`virtual machine` at a time.
|
only one thread executes Python :term:`bytecode` at a time.
|
||||||
This simplifies the CPython implementation by assuring that no two
|
This simplifies the CPython implementation by making the object model
|
||||||
processes can access the same memory at the same time. Locking the
|
(including critical built-in types such as :class:`dict`) implicitly
|
||||||
entire interpreter makes it easier for the interpreter to be
|
safe against concurrent access. Locking the entire interpreter
|
||||||
multi-threaded, at the expense of much of the parallelism afforded by
|
makes it easier for the interpreter to be multi-threaded, at the
|
||||||
multi-processor machines. Efforts have been made in the past to
|
expense of much of the parallelism afforded by multi-processor
|
||||||
create a "free-threaded" interpreter (one which locks shared data at a
|
machines.
|
||||||
much finer granularity), but so far none have been successful because
|
|
||||||
performance suffered in the common single-processor case.
|
However, some extension modules, either standard or third-party,
|
||||||
|
are designed so as to release the GIL when doing computationally-intensive
|
||||||
|
tasks such as compression or hashing. Also, the GIL is always released
|
||||||
|
when doing I/O.
|
||||||
|
|
||||||
|
Past efforts to create a "free-threaded" interpreter (one which locks
|
||||||
|
shared data at a much finer granularity) have not been successful
|
||||||
|
because performance suffered in the common single-processor case. It
|
||||||
|
is believed that overcoming this performance issue would make the
|
||||||
|
implementation much more complicated and therefore costlier to maintain.
|
||||||
|
|
||||||
hashable
|
hashable
|
||||||
An object is *hashable* if it has a hash value which never changes during
|
An object is *hashable* if it has a hash value which never changes during
|
||||||
|
|
|
@ -26,11 +26,22 @@ The :mod:`dummy_threading` module is provided for situations where
|
||||||
Starting with Python 2.5, several Thread methods raise :exc:`RuntimeError`
|
Starting with Python 2.5, several Thread methods raise :exc:`RuntimeError`
|
||||||
instead of :exc:`AssertionError` if called erroneously.
|
instead of :exc:`AssertionError` if called erroneously.
|
||||||
|
|
||||||
|
.. impl-detail::
|
||||||
|
|
||||||
|
Due to the :term:`Global Interpreter Lock`, in CPython only one thread
|
||||||
|
can execute Python code at once (even though certain performance-oriented
|
||||||
|
libraries might overcome this limitation).
|
||||||
|
If you want your application to make better of use of the computational
|
||||||
|
resources of multi-core machines, you are advised to use
|
||||||
|
:mod:`multiprocessing`. However, threading is still an appropriate model
|
||||||
|
if you want to run multiple I/O-bound tasks simultaneously.
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
Latest version of the `threading module Python source code
|
Latest version of the `threading module Python source code
|
||||||
<http://svn.python.org/view/python/branches/release27-maint/Lib/threading.py?view=markup>`_
|
<http://svn.python.org/view/python/branches/release27-maint/Lib/threading.py?view=markup>`_
|
||||||
|
|
||||||
|
|
||||||
This module defines the following functions and objects:
|
This module defines the following functions and objects:
|
||||||
|
|
||||||
.. function:: active_count()
|
.. function:: active_count()
|
||||||
|
|
Loading…
Reference in New Issue