10000 bpo-43693: Compute deref offsets in compiler by markshannon · Pull Request #25152 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-43693: Compute deref offsets in compiler #25152

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

Merged
Prev Previous commit
Next Next commit
Clarify the LOAD_FAST docs.
  • Loading branch information
ericsnowcurrently committed Jun 3, 2021
commit e4bf977947270ee526ce439fdf713679d7e7053a
15 changes: 12 additions & 3 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,20 @@ All of the following opcodes use their arguments.

.. opcode:: LOAD_FAST (var_num)

Pushes a reference to the local ``co_varnames[var_num]`` onto the stack.
Closures are also handled by this operation.
Pushes a reference to a local variable or closure cell onto the stack.
The corresponding variable name is
``(co_varnames + co_cellvars + co_freevars)[var_num]``.

For closures, note that ``LOAD_FAST`` loads the cell object contained
in the corresponding slot of the cell and free variable storage,
at index ``var_num - len(co_varnames)``.
In contrast, ``LOAD_DEREF`` gets the object the cell references.

Use of ``LOAD_FAST`` for closures is primarily to share cells objects
from an outer closure when creating an inner one with ``MAKE_FUNCTION``.

.. versionchanged:: 3.10
Closures are handled here now instead of ``LOAD_CLOSURE`` (removed).
Closure cells are handled here now instead of ``LOAD_CLOSURE`` (removed).


.. opcode:: STORE_FAST (var_num)
Expand Down
0