]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-125832: Clarify comment for inlined comprehensions as per P… (gh-126345)
authorDonghee Na <donghee.na@python.org>
Sun, 3 Nov 2024 04:00:52 +0000 (13:00 +0900)
committerGitHub <noreply@github.com>
Sun, 3 Nov 2024 04:00:52 +0000 (04:00 +0000)
* [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) <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>
* Add space

---------

Co-authored-by: rimchoi <hyerimc858@gmail.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
Co-authored-by: RUANG (James Roy) <longjinyii@outlook.com>
Python/compile.c

index 49b2ebf003bad491eadfaf94ef5d27d5e82e11d4..6050b7281fa051d19bf6a0fa43f3d980088b2612 100644 (file)
@@ -5191,9 +5191,12 @@ ex_call:
 }
 
 
-/* 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