Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document FrameLocalsProxy behaviour quirks #125731

Open
ncoghlan opened this issue Oct 19, 2024 · 0 comments
Open

Document FrameLocalsProxy behaviour quirks #125731

ncoghlan opened this issue Oct 19, 2024 · 0 comments
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes docs Documentation in the Doc dir triaged The issue has been accepted as valid by a triager.

Comments

@ncoghlan
Copy link
Contributor

ncoghlan commented Oct 19, 2024

Following PEP 667, https://docs.python.org/dev/reference/datamodel.html#frame-objects mentions that frame.f_locals may be a write-through proxy object, but doesn't really explain what that means.

Once python/peps#3845 lands PEP 667 will contain such a description, but the main docs should at least cover the key behaviours:

  • new instance on every attribute access
  • two proxies with the same keys and values will still be unequal if they refer to different frames
  • extra keys can be stored and are stored on the frame itself so they're shared across all proxies for the same frame
  • keys corresponding to local variables can't be deleted
  • .copy() (and any other API that produces a new container) returns a regular dict instance

Suggested location would be as a new 4th subsection under the frame objects section linked above. A "see also" from that new subsection back to PEP 667 would also be a useful addition.

@ncoghlan ncoghlan added docs Documentation in the Doc dir triaged The issue has been accepted as valid by a triager. 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels Oct 19, 2024
@python python deleted a comment from ANURAGSINGHASR Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes docs Documentation in the Doc dir triaged The issue has been accepted as valid by a triager.
Projects
Status: Todo
Development

No branches or pull requests

1 participant