- Glossary - G
- ********
- garbage collection
- The process of freeing memory when it is not used anymore. Python
- performs garbage collection via reference counting and a cyclic
- garbage collector that is able to detect and break reference
- cycles. The garbage collector can be controlled using the "gc"
- module.
- generator
- A function which returns a *generator iterator*. It looks like a
- normal function except that it contains "yield" expressions for
- producing a series of values usable in a for-loop or that can be
- retrieved one at a time with the "next()" function.
- Usually refers to a generator function, but may refer to a
- *generator iterator* in some contexts. In cases where the intended
- meaning isn't clear, using the full terms avoids ambiguity.
- generator iterator
- An object created by a *generator* function.
- Each "yield" temporarily suspends processing, remembering the
- location execution state (including local variables and pending
- try-statements). When the *generator iterator* resumes, it picks
- up where it left off (in contrast to functions which start fresh on
- every invocation).
- generator expression
- An expression that returns an iterator. It looks like a normal
- expression followed by a "for" clause defining a loop variable,
- range, and an optional "if" clause. The combined expression
- generates values for an enclosing function:
- >>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81
- 285
- generic function
- A function composed of multiple functions implementing the same
- operation for different types. Which implementation should be used
- during a call is determined by the dispatch algorithm.
- See also the *single dispatch* glossary entry, the
- "functools.singledispatch()" decorator, and **PEP 443**.
- generic type
- A *type* that can be parameterized; typically a container class
- such as "list" or "dict". Used for *type hints* and *annotations*.
- For more details, see generic alias types, **PEP 483**, **PEP
- 484**, **PEP 585**, and the "typing" module.
- GIL
- See *global interpreter lock*.
- global interpreter lock
- The mechanism used by the *CPython* interpreter to assure that only
- one thread executes Python *bytecode* at a time. This simplifies
- the CPython implementation by making the object model (including
- critical built-in types such as "dict") implicitly safe against
- concurrent access. Locking the entire interpreter makes it easier
- for the interpreter to be multi-threaded, at the expense of much of
- the parallelism afforded by multi-processor machines.
- 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.
Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.
Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.
See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license