Skip to content

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

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

gh-124697: Represent inlined comprehensions as subscopes in the symbol table#156819
iritkatriel wants to merge 3 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 to 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

Documentation build overview

📚 cpython-previews | 🛠️ Build #34351502 | 📁 Comparing 97ace7d against main (d557d64)

  🔍 Preview build  

3 files changed
± library/symtable.html
± whatsnew/3.16.html
± whatsnew/changelog.html

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

1 participant