Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outdated post PEP-709 comment in Python/codegen.c #125832

Closed
Eclips4 opened this issue Oct 22, 2024 · 5 comments
Closed

Outdated post PEP-709 comment in Python/codegen.c #125832

Eclips4 opened this issue Oct 22, 2024 · 5 comments
Assignees
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@Eclips4
Copy link
Member

Eclips4 commented Oct 22, 2024

Bug report

Bug description:

After the implementation of https://peps.python.org/pep-0709/, this comment looks wrong:

cpython/Python/codegen.c

Lines 4079 to 4090 in 57e3c59

/* 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.
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
flagged in symtable.c as a generator, so it returns the generator object
when the function is called.
Possible cleanups:
- iterate over the generator sequence instead of using recursion
*/

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

@Eclips4 Eclips4 added type-bug An unexpected behavior, bug, or error easy labels Oct 22, 2024
@picnixz
Copy link
Contributor

picnixz commented Oct 22, 2024

Haven't checked in the code yet but generator expressions do not seem to be concerned by the inlining:

Generator expressions are currently not inlined in the reference implementation of this PEP. In the future, some generator expressions may be inlined, where the returned generator object does not leak.

@picnixz picnixz added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Oct 22, 2024
@rimi0108
Copy link
Contributor

rimi0108 commented Nov 2, 2024

I will take a look :)

@corona10
Copy link
Member

corona10 commented Nov 2, 2024

@willingc

@rimi0108 is going to take a look at this issue during the KR sprint too :)

@picnixz picnixz changed the title Outdated comment in Python/codegen.c Outdated post PEP-709 comment in Python/codegen.c Nov 2, 2024
willingc added a commit that referenced this issue Nov 2, 2024
…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]>
@corona10
Copy link
Member

corona10 commented Nov 3, 2024

Thanks for the contribution! @rimi0108

@corona10 corona10 closed this as completed Nov 3, 2024
@corona10 corona10 reopened this Nov 3, 2024
@corona10
Copy link
Member

corona10 commented Nov 3, 2024

We need to handle backport patch as well.

corona10 pushed a commit to corona10/cpython that referenced this issue Nov 3, 2024
…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)
corona10 pushed a commit to corona10/cpython that referenced this issue Nov 3, 2024
… per PEP-709 (pythongh-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]>
corona10 added a commit to corona10/cpython that referenced this issue Nov 3, 2024
corona10 added a commit that referenced this issue Nov 3, 2024
gh-126345)

* [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) <[email protected]>

* Add reference to PEP 709

---------

Co-authored-by: Carol Willing <[email protected]>
Co-authored-by: RUANG (James Roy) <[email protected]>

* Add space

---------

Co-authored-by: rimchoi <[email protected]>
Co-authored-by: Carol Willing <[email protected]>
Co-authored-by: RUANG (James Roy) <[email protected]>
corona10 added a commit that referenced this issue Nov 3, 2024
…EP-709 (gh-126322) (gh-126344)

* 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) <[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)

* Add space

---------

Co-authored-by: rimchoi <[email protected]>
@corona10 corona10 closed this as completed Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants