~/talk

The chaotic locals() and how we fixed it

Talkat PyCon US 2025 · 2025-05-16..05-18· [python]
name:Tian Gao
links:none on file
slides:none on file

Python changes local-variable semantics with PEP 667: locals() returns a fresh snapshot dict so reads never implicitly mutate fast locals and repeated calls return new dicts, while frame.f_locals becomes a write-through proxy that immediately updates the underlying C-array locals so debuggers can exec and mutate reliably. The implementation replaces ad hoc fast-to-locals hacks that caused PDB commands like ll to revert edits and it lands in CPython, removing the surprising behaviors that broke real debugger workflows.

AI-written summary · about

  1. 0:00Introduction
  2. 1:10First bug in CPython
  3. 3:21Python local scope history
  4. 5:50Fast locals in CPython
  5. 8:03Broken locals and fast locals
  6. 11:15Exec and locals behavior
  7. 14:26Debugger challenges
  8. 18:23Locals behavior needs fixing
  9. 19:45PEP 667 goals
  10. 20:26PEP 667 semantics
  11. 21:11Frame.f locals proxy
  12. 23:21Debugger improvements
  13. 24:50Q&A with Mark Shannon
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.