Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update frame.rst
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
  • Loading branch information
ZeroIntensity and AlexWaygood authored Dec 9, 2024
commit 8ec995f618a2f56f3f1ca3b4a889f28f40e83503
11 changes: 5 additions & 6 deletions Doc/c-api/frame.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,11 @@ Frame Locals Proxies

.. versionadded:: 3.13

In older versions of :term:`CPython`, the exposed local variables dictionary
(via :attr:`~frame.f_locals`, :c:func:`PyFrame_GetLocals`, or :func:`locals`)
wasn't consistent with the actual local variables, which lead to all sorts of
weird issues. In Python 3.13, instead of using a dictionary to expose locals,
a special proxy type that retains consistency when manipulating
scopes is used.
The :attr:`~frame.f_locals` attribute on a :ref:`frame object <frame-objects>`
is an instance of a "frame-locals proxy". The proxy object exposes a
write-through view of the underlying locals dictionary for the frame. This
ensures that the variables exposed by ``f_locals`` are always up to date with
the live local variables in the frame itself.

See :pep:`667` for more information.

Expand Down