Skip to content

gh-124697: Represent inlined comprehensions as subscopes in the symbol table - #156819

Open
iritkatriel wants to merge 18 commits into
python:mainfrom
iritkatriel:subscope
Open

gh-124697: Represent inlined comprehensions as subscopes in the symbol table#156819
iritkatriel wants to merge 18 commits into
python:mainfrom
iritkatriel:subscope

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Sep 2, 2026

Copy link
Copy Markdown
Member

Resolves #124697

Inlined comprehensions are now represented in the symbol table as block of a new type InlinedComprehensionBlock, which is a subscope of the enclosing scope and is interpreted as the delta between the containing scope and the comprehension scope. Symbol lookups that
fail in the subscope continue in the containing scope.

This moves the complexity of compiling inlined comprehensions from codegen to the symbol table
construction.

It removes the smell of the compiler modifying the symbol table in codegen.

iritkatriel and others added 2 commits September 2, 2026 12:12
…l tables

Co-authored-by: Cursor <cursoragent@cursor.com>
@read-the-docs-community

read-the-docs-community Bot commented Sep 2, 2026

Copy link
Copy Markdown

@carljm carljm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thank you for working on this ❤️

Comment thread Python/symtable.c Outdated
Comment thread Python/symtable.c
Comment thread Python/codegen.c
Comment thread Python/symtable.c Outdated
Comment thread Python/symtable.c Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor the implementation of inlined comprehensions

2 participants