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

refactor the implementation of inlined comprehensions #124697

Open
carljm opened this issue Sep 27, 2024 · 1 comment
Open

refactor the implementation of inlined comprehensions #124697

carljm opened this issue Sep 27, 2024 · 1 comment
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@carljm
Copy link
Member

carljm commented Sep 27, 2024

The current implementation of comprehension inlining is a pile of special cases that is quite difficult to understand and debug. The root cause of this is that it attempts to flatten the inlined scope into the enclosing scope in the symbol table, to avoid the compiler needing to generally understand the concept of inlined sub-scopes, but this flattening loses information and requires a number of special cases. And then the compiler implementation of inlining modifies the flattened scope as it traverses the inlined comprehension(s) in order to ensure correct handling of the names within the inlined sub-scope; ideally the compiler would not modify the symbol table as it generates code.

A better implementation would leave the scopes separate in the symbol table, losing no information but just marking the comprehension scope as an inlined sub-scope, and then add explicit support for inlined sub-scopes in the compiler (with appropriate query methods in the symtable.)

@carljm carljm self-assigned this Sep 27, 2024
@carljm carljm added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Sep 27, 2024
@carljm
Copy link
Member Author

carljm commented Sep 27, 2024

cc @iritkatriel @JelleZijlstra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

1 participant