diff options
author | Alyssa Coghlan <ncoghlan@gmail.com> | 2024-10-08 07:52:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-08 07:52:12 (GMT) |
commit | 27390990fa9306e2a797a4eb2bd83c5bfc7cb186 (patch) | |
tree | b103ae76df4d6650724f29645053267d75b4ff95 /Doc/c-api | |
parent | cc9b9bebb2c09c475cb0f278268cce03c115eaea (diff) | |
download | cpython-27390990fa9306e2a797a4eb2bd83c5bfc7cb186.zip cpython-27390990fa9306e2a797a4eb2bd83c5bfc7cb186.tar.gz cpython-27390990fa9306e2a797a4eb2bd83c5bfc7cb186.tar.bz2 |
gh-70870: Clarify dual usage of 'free variable' (#122545)
The term "free variable" has unfortunately become genuinely
ambiguous over the years (presumably due to the names of
some relevant code object instance attributes).
While we can't eliminate that ambiguity at this late date, we can
at least alert people to the potential ambiguity by describing
both the formal meaning of the term and the common
alternative use as a direct synonym for "closure variable".
---------
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Diffstat (limited to 'Doc/c-api')
-rw-r--r-- | Doc/c-api/code.rst | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/c-api/code.rst b/Doc/c-api/code.rst index 6ae6bfe..6eae24b 100644 --- a/Doc/c-api/code.rst +++ b/Doc/c-api/code.rst @@ -32,11 +32,13 @@ bound into a function. .. c:function:: Py_ssize_t PyCode_GetNumFree(PyCodeObject *co) - Return the number of free variables in a code object. + Return the number of :term:`free (closure) variables <closure variable>` + in a code object. .. c:function:: int PyUnstable_Code_GetFirstFree(PyCodeObject *co) - Return the position of the first free variable in a code object. + Return the position of the first :term:`free (closure) variable <closure variable>` + in a code object. .. versionchanged:: 3.13 @@ -144,7 +146,8 @@ bound into a function. Equivalent to the Python code ``getattr(co, 'co_freevars')``. Returns a new reference to a :c:type:`PyTupleObject` containing the names of - the free variables. On error, ``NULL`` is returned and an exception is raised. + the :term:`free (closure) variables <closure variable>`. On error, ``NULL`` is returned + and an exception is raised. .. versionadded:: 3.11 |