Title: Enable PEP 709 inlined comprehensions by youknowone · Pull Request #7412 · RustPython/RustPython · GitHub
Open Graph Title: Enable PEP 709 inlined comprehensions by youknowone · Pull Request #7412 · RustPython/RustPython
X Title: Enable PEP 709 inlined comprehensions by youknowone · Pull Request #7412 · RustPython/RustPython
Description: Summary Activate the existing compile_inlined_comprehension() implementation by fixing 6 bugs that prevented it from working List/dict/set comprehensions inside function-like scopes are now compiled inline (no separate code object), matching CPython 3.12+ behavior Generator expressions remain non-inlined per PEP 709 spec Changes frame.rs: LoadFastAndClear pushes NULL when slot is empty (not None), StoreFast accepts NULL for restore path compile.rs: Enable is_inlined_comprehension_context(), fix in_inlined_comp flag placement, fix sub_tables.remove(0) → next_sub_table cursor, splice nested sub_tables into parent symboltable.rs: Set comp_inlined only in function-like parent scopes, conflict detection (nested scopes, bound name conflicts, cross-comprehension reference conflicts) Current limitations Module/class level comprehensions are not inlined (STORE_NAME incompatible with LOAD_FAST_AND_CLEAR) Comprehensions containing nested scopes (lambda, inner function, inner comprehension) are not inlined (Cell/Free handling not yet supported) Bound name conflicts with parent scope → falls back to non-inlined Test plan test_listcomps — 59/59 pass test_setcomps — pass test_symtable — pass test_dictcomps — 1 pre-existing failure (unrelated) test_compile, test_syntax — pass cargo test -p rustpython-codegen -p rustpython-compiler — pass Variable isolation, outer references, nested comprehensions, walrus operator — all verified 🤖 Generated with Claude Code Summary by CodeRabbit Refactor Comprehension inlining tightened: only inline in function-like scopes, skip generator/async comprehensions, and preserve inlined state for nested comprehensions and lambdas. Symbol-table merging hardened: track symbols added by inlining, prevent name conflicts and improper resolutions, and refine scope propagation rules. Runtime locals behavior adjusted: cleared/empty local slots use a nullable representation, aligning push/pop semantics and preserving variable lifecycle consistency. Bug Fixes Improved handling of scope visibility to avoid incorrect symbol resolution after inlining.
Open Graph Description: Summary Activate the existing compile_inlined_comprehension() implementation by fixing 6 bugs that prevented it from working List/dict/set comprehensions inside function-like scopes are now compil...
X Description: Summary Activate the existing compile_inlined_comprehension() implementation by fixing 6 bugs that prevented it from working List/dict/set comprehensions inside function-like scopes are now compil...
Opengraph URL: https://github.com/RustPython/RustPython/pull/7412
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:7b941107-c65e-2f7c-78db-51d0f30fe8ff |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B17C:277230:1AFE182:241FD70:6A5BAE26 |
| html-safe-nonce | 752208f6daa1c13cf006e1fcff51ab0230ed81552da1351dbbb5090e72ed9928 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTdDOjI3NzIzMDoxQUZFMTgyOjI0MUZENzA6NkE1QkFFMjYiLCJ2aXNpdG9yX2lkIjoiODEzNDIxMDEwMDkzMDUyMjY2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2f43d7304f10afaf8e23f9b0951d151d0fef10a7461dffc55a1c2c5c19ff7563 |
| hovercard-subject-tag | pull_request:3390079483 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/7412/files |
| twitter:image | https://avatars.githubusercontent.com/u/69878?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/69878?s=400&v=4 |
| og:image:alt | Summary Activate the existing compile_inlined_comprehension() implementation by fixing 6 bugs that prevented it from working List/dict/set comprehensions inside function-like scopes are now compil... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width