Document FrameLocalsProxy behaviour quirks

未关闭 适合新手
#125,731 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
documentation

调研方向

从 Python 数据模型文档中的 frame 对象部分开始,并审阅 PEP 667,包括其中链接的 PEP pull request。添加第四个子小节,描述列出的 FrameLocalsProxy 的五种行为,并添加一个返回 PEP 667 的参见链接。完成的标准是主文档解释代理标识、共享的额外键、不可删除的局部变量以及生成字典的 API。

由索引模型根据 Issue 内容生成。

描述

3.13 3.14 docs triaged

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 https://github.com/python/peps/pull/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.

Linked PRs
  • gh-157869
主要语言
Python
星标
77.2k
派生
36k
平均合并
1 天 11 小时
30 天内合并 PR
565

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python/cpython 的其他 Issue

查看 python/cpython 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。