Skip to content

Commit 868bfcc

Browse files
rimi0108willingcrruuaanng
authored
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) <longjinyii@outlook.com> * Add reference to PEP 709 --------- Co-authored-by: Carol Willing <carolcode@willingconsulting.com> Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com>
1 parent bd4be5e commit 868bfcc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: Python/codegen.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -4087,9 +4087,12 @@ codegen_call_helper(compiler *c, location loc,
40874087
return codegen_call_helper_impl(c, loc, n, args, NULL, keywords);
40884088
}
40894089

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

0 commit comments

Comments
 (0)