~/talk

Make a working implementation of async functions in Python 2.1

Talkat PyBay 2024 · on Saturday, 2024-09-21· [python, compilers-and-language-design]
slides:none on file

Builds a working async/coroutine system that runs on Python 1.6 by reimplementing three pieces: yield-from emulation via a stack of iterators (works back to ~2.2), a hand-rolled bidirectional channel protocol that mimics send/throw (covers 2.5 semantics), and a tiny bytecode patching resume trick driven by sys.settrace to jump to the next source line. Code patches a function’s code object with the marshal/C API, so suspendable coroutines work (locals omitted) and the demo runs on Python 1.6.

AI-written summary · about

  1. 0:00Introduction and apology
  2. 0:48Why modern Python feels complex
  3. 2:15What are async functions
  4. 3:40Challenges in Python 1.6
  5. 4:22Async/await syntax basics
  6. 5:26Generator delegation with yield from
  7. 7:36Implementing yield from manually
  8. 9:21Bidirectional communication with channels
  9. 11:29The role of yield in Python
  10. 12:55Exploring Python bytecode
  11. 14:41Tracing execution with sys.settrace
  12. 16:49Building a suspendable class
  13. 18:36Unsuspending with patched bytecode
  14. 20:44Testing async in Python 1.6
  15. 21:50Why newer Python is better
  16. 22:54History of Python features
  17. 26:26Python’s design philosophy
  18. 28:12Summary and Q&A
~/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.