Skip to content

Commit

Permalink
pythongh-125832: Clarify comment for inlined comprehensions as per PE…
Browse files Browse the repository at this point in the history
…P-709 (python#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)
  • Loading branch information
rimi0108 authored and corona10 committed Nov 3, 2024
1 parent 2f77931 commit 62ddc5f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -5314,10 +5314,12 @@ compiler_call_helper(struct compiler *c, location loc,
return SUCCESS;
}


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

0 comments on commit 62ddc5f

Please sign in to comment.