@@ -1098,46 +1098,17 @@ are always available. They are listed here in alphabetical order.
1098
1098
Calling ``locals() `` as part of a generator expression is equivalent to
1099
1099
calling it in a nested generator function.
1100
1100
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 `.
1117
1104
1118
1105
.. 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.
1123
1111
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.
1141
1112
1142
1113
.. function :: map(function, iterable, *iterables)
1143
1114
0 commit comments