Need more info regarding cells and closures.
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
Cell variable
Since "free variable" is defined in 4.2.1. Binding of names, I suggest also defining a "cell variable", as any local variable whose name is resolved to that scope in some enclosed scope.
Also, the term "free variable" is used elsewhere in the docs, where it means that the variable is resolved in an enclosing function scope, and does not include if the variable is resolved in the module scope.
exec(..., closure=...)
The closure argument specifies a closure–a tuple of cellvars. It’s only valid when the object is a code object containing free variables. The length of the tuple must exactly match the number of free variables referenced by the code object.
- Use the name 'func' to refer to the function involved.
func.__code__is the object given toexec(). - Instead of 'cellvars', say 'bindings for free variables in 'func'.' Refer to new 'Cell objects' section of the Type Hierarchy.
- The bindings are in the same order as the names of the free variables found in
code.co_freevars. - The bindings can be found in
func.__closure. func.__closure__reflects values of the free variables at the timeexecis called, which may have changed sincefuncwas created.- Bindings in
closurecan be modified by the code if the variable names are declared nonlocal infunc. If 'closure' isfunc.__closure__, then the 'func' free variables will have changed. - Refer to new 'Cell Objects' section in the Type Hierarchy for details.
Type Hierarchy
Add a section for 'Cell Objects' under 'Internal types'.
- The name of the class is 'cell', and the class is available in
types.CellType. - It represents the binding of a free or cell variable.
- It may have a current value (any Python object), or it may be empty.
cell()is an empty cell.cell(obj)is a cell withobjas its current value.cell.cell_contentsis a writable attribute returning the current value, if any, or raising ValueError if empty. It may be assigned a new value or deleted (without raising an exception if already empty).- Cells may be compared by their values. Empty cells compare < non-empty cells.
Mention that Frame objects have class 'frame', which is types.FrameType. There is no explicit constructor.
User-defined functions section:
- Add an id=user-defined-functions tag to the HTML so that it can be linked to as a fragment.
- Under closure, refer to the new 'Cell objects' section, instead of the later paragraph about cells.
inspect.getmembers
Add entry for 'closure' under 'function'. Use same text as above in the user-defined functions section.
Entry for 'co_cellvars' under 'code', should read 'contained scopes' instead of 'containing scopes'. And it is only for names in 'co_varnames'.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている exec(closure=...)、Type Hierarchy、ユーザー定義関数、inspect.getmembers のドキュメントセクションから始めてください。要求された用語と相互参照を更新する前に、自由変数、セル変数、クロージャ、フレームの既存の定義を確認してください。影響を受けるセクションで、要求されたセルとクロージャの動作が一貫して説明されていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100