]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-125832: Clarify comment for inlined comprehensions as per PEP-709 (#126322)
authorrimchoi <hyerimc858@gmail.com>
Sat, 2 Nov 2024 17:04:53 +0000 (02:04 +0900)
committerGitHub <noreply@github.com>
Sat, 2 Nov 2024 17:04:53 +0000 (17:04 +0000)
* 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>
Python/codegen.c

index d79aee4859e51b1198f8fad1de386a014fbefec5..c060ed76f1eb5c193fe35ad6f1c7a7b5bd1ddb96 100644 (file)
@@ -4087,9 +4087,12 @@ codegen_call_helper(compiler *c, location loc,
     return codegen_call_helper_impl(c, loc, n, args, NULL, keywords);
 }
 
-/* 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