Skip to content

Commit 4afa129

Browse files
corona10rimi0108willingcrruuaanng
authored
[3.12] gh-125832: Clarify comment for inlined comprehensions as per P… (gh-126345)
* [3.12] gh-125832: Clarify comment for inlined comprehensions as per PEP-709 (gh-126322) * Fix comprehensions comment to inlined by pep 709 * Update spacing Co-authored-by: RUANG (James Roy) <[email protected]> * Add reference to PEP 709 --------- Co-authored-by: Carol Willing <[email protected]> Co-authored-by: RUANG (James Roy) <[email protected]> * Add space --------- Co-authored-by: rimchoi <[email protected]> Co-authored-by: Carol Willing <[email protected]> Co-authored-by: RUANG (James Roy) <[email protected]>
1 parent f4bc64d commit 4afa129

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Python/compile.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5191,9 +5191,12 @@ compiler_call_helper(struct compiler *c, location loc,
51915191
}
51925192

51935193

5194-
/* List and set comprehensions and generator expressions work by creating a
5195-
nested function to perform the actual iteration. This means that the
5196-
iteration variables don't leak into the current scope.
5194+
/* List and set comprehensions work by being inlined at the location where
5195+
they are defined. The isolation of iteration variables is provided by
5196+
pushing/popping clashing locals on the stack. Generator expressions work
5197+
by creating a nested function to perform the actual iteration.
5198+
This means that the iteration variables don't leak into the current scope.
5199+
See https://peps.python.org/pep-0709/ for additional information.
51975200
The defined function is called immediately following its definition, with the
51985201
result of that call being the result of the expression.
51995202
The LC/SC version returns the populated container, while the GE version is

0 commit comments

Comments
 (0)