Skip to content

gh-125731: Document FrameLocalsProxy behaviour quirks in datamodel.rst - #157869

Open
VimalN2005 wants to merge 1 commit into
python:mainfrom
VimalN2005:docs/framelocalsproxy-quirks
Open

VimalN2005 wants to merge 1 commit into
python:mainfrom
VimalN2005:docs/framelocalsproxy-quirks

Conversation

@VimalN2005

Copy link
Copy Markdown

What's changed?

Fixes gh-125731.

This PR documents the key behaviours of the write-through FrameLocalsProxy object returned by frame.f_locals in optimized scopes under Doc/reference/datamodel.rst, following PEP 667 and the requirements outlined by @ncoghlan:

  • Adds a new 4th subsection Frame locals proxy behaviour under the Frame Objects section.
  • Documents the 5 key proxy behaviours:
    1. A new proxy instance is returned on every access to frame.f_locals.
    2. Two proxy instances with the same keys and values compare unequal if they refer to different frame objects.
    3. Extra keys can be stored in the proxy and are stored on the frame itself, shared across all proxies for that frame.
    4. Keys corresponding to local variables defined in the function cannot be deleted (KeyError).
    5. Calling .copy() returns a standard dict instance.
  • Adds a .. seealso:: linking to PEP 667.
  • Links frame.f_locals attribute documentation directly to this new subsection.

Documentation-only change.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34662367 | 📁 Comparing 07c0e79 against main (a64b7ec)

  🔍 Preview build  

1 file changed
± reference/datamodel.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Document FrameLocalsProxy behaviour quirks

1 participant