Skip to content

Implement PEP 667 frame locals semantics - #8602

Draft
youknowone wants to merge 2 commits into
RustPython:mainfrom
youknowone:locals-proxy
Draft

Implement PEP 667 frame locals semantics#8602
youknowone wants to merge 2 commits into
RustPython:mainfrom
youknowone:locals-proxy

Conversation

@youknowone

Copy link
Copy Markdown
Member

Summary

  • implement PEP 667 live frame-locals proxies and fresh locals() snapshots
  • correctly expose PEP 709 hidden comprehension locals without leaking them into module or custom namespaces
  • make frame clearing and overwritten-local retention safe against finalizer reentrancy
  • add O(1) locals-plus name lookup so proxy snapshots remain O(n)
  • layer PyEval_GetLocals() on a separate lazy C-API-only cache so ordinary VM execution pays no C-API cache maintenance cost
  • add standalone frame-locals regression tests

Tests

  • cargo test -p rustpython-vm — 70 passed, doctests passed
  • (cd crates/capi && cargo test) — 103 passed
  • CPython extra_tests/snippets/vm_frame_locals.py — 10 passed
  • RustPython extra_tests/snippets/vm_frame_locals.py — 10 passed
  • cargo fmt --all -- --check
  • pre-commit hooks

AI assistance

Implementation and review were assisted by Codex. The commit includes the required Assisted-by trailer.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[x] test: cpython/Lib/test/test_list.py (TODO: 3)
[x] test: cpython/Lib/test/test_listcomps.py
[ ] test: cpython/Lib/test/test_userlist.py (TODO: 1)

dependencies:

dependent tests: (no tests depend on list)

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

Assisted-by: Codex:GPT-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant