diff options
author | rimchoi <hyerimc858@gmail.com> | 2024-11-02 17:04:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-02 17:04:53 (GMT) |
commit | 868bfcc02ed42a1042851830b79c6877b7f1c7a8 (patch) | |
tree | 0007438b4c10c5ed1af3198c716269f94d459af2 /Python/codegen.c | |
parent | bd4be5e67de5f31e9336ba0fdcd545e88d70b954 (diff) | |
download | cpython-868bfcc02ed42a1042851830b79c6877b7f1c7a8.zip cpython-868bfcc02ed42a1042851830b79c6877b7f1c7a8.tar.gz cpython-868bfcc02ed42a1042851830b79c6877b7f1c7a8.tar.bz2 |
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>
Diffstat (limited to 'Python/codegen.c')
-rw-r--r-- | Python/codegen.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Python/codegen.c b/Python/codegen.c index d79aee4..c060ed7 100644 --- a/Python/codegen.c +++ b/Python/codegen.c @@ -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 |