8000 Simplify locals() versionchanged notes · python/cpython@ebcf2d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit ebcf2d0

Browse files
committed
Simplify locals() versionchanged notes
1 parent 6e3f1d1 commit ebcf2d0

File tree

1 file changed

+8
-37
lines changed

1 file changed

+8
-37
lines changed

Doc/library/functions.rst

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,46 +1098,17 @@ are always available. They are listed here in alphabetical order.
10981098
Calling ``locals()`` as part of a generator expression is equivalent to
10991099
calling it in a nested generator function.
11001100

1101-
.. versionchanged:: 3.13
1102-
As part of :pep:`667`, the semantics of mutating the mapping object
1103-
returned from this function are now formally defined. The behavior in
1104-
functions, generators, coroutines, comprehensions, and generator
1105-
expressions is now as described above. Aside from being defined, the
1106-
behaviour in other scopes remains unchanged from previous versions.
1107-
1108-
.. versionchanged:: 3.13
1109-
As part of :pep:`667`, the mapping returned when called in a function,
1110-
generator, coroutine, comprehension or generator expression is an
1111-
independent snapshot of the currently assigned local and locally
1112-
referenced nonlocal variables. In CPython specifically, the mapping
1113-
returned in these scopes could previously be implicitly refreshed by other
1114-
operations, such as calling ``locals()`` again. Obtaining the legacy
1115-
CPython behaviour now requires explicit calls to update the initially
1116-
returned dictionary with the results of subsequent calls to ``locals()``.
1101+
.. versionchanged:: 3.12
1102+
The behaviour of ``locals()`` in a comprehension has been updated as
1103+
described in :pep:`709`.
11171104

11181105
.. versionchanged:: 3.13
1119-
As part of :pep:`667`, calling ``locals()`` in a comprehension at module
1120-
or class scope (including via ``exec`` or ``eval``) once more behaves as if
1121-
the comprehension were running as an independent nested function (i.e.
1122-
the local variables from the containing scope are not included).
1106+
As part of :pep:`667`, the semantics of mutating the mapping objects
1107+
returned from this function are now defined. The behavior in
1108+
:term:`optimised scopes <optimised scope>` is now as described above.
1109+
Aside from being defined, the behaviour in other scopes remains
1110+
unchanged from previous versions.
11231111

1124-
.. versionchanged:: 3.12
1125-
As part of :pep:`709`, calling ``locals()`` in a comprehension at module
1126-
or class scope (including via ``exec`` or ``eval``) produces an independent
1127-
snapshot of the containing scope with the comprehension iteration
1128-
variable(s) included.
1129-
1130-
.. versionchanged:: 3.12
1131-
As part of :pep:`709`, calling ``locals()`` in a comprehension as part of a
1132-
function, generator, or coroutine returns the same ``locals()`` reference
1133-
as calls in the containing scope.
1134-
1135-
..
1136-
Possible simplification: change the 3.12 note to just "Changes to
1137-
behavior in comprehensions as described in :pep:`709`", and do somethine
1138-
similar for 3.13 and :pep:`667`. While the draft change notes are
1139-
comprehensive, they're also almost entirely in the "Who is really going
1140-
to care?" category.
11411112

11421113
.. function:: map(function, iterable, *iterables)
11431114

0 commit comments

Comments
 (0)
0