Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36079f7

Browse files
corona10rimi0108
andauthored
[3.13] gh-125832: Clarify comment for inlined comprehensions as per PEP-709 (gh-126322) (gh-126344)
* gh-125832: Clarify comment for inlined comprehensions as per PEP-709 (#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]> (cherry picked from commit 868bfcc) * Add space --------- Co-authored-by: rimchoi <[email protected]>
1 parent 2f77931 commit 36079f7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Python/compile.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -5315,9 +5315,12 @@ compiler_call_helper(struct compiler *c, location loc,
53155315
}
53165316

53175317

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

0 commit comments

Comments
 (0)