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 comment in Python/codegen.c #125832

Open
Eclips4 opened this issue Oct 22, 2024 · 1 comment
Open

Outdated comment in Python/codegen.c #125832

Eclips4 opened this issue Oct 22, 2024 · 1 comment
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

@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
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

2 participants