~/talk

Demystifying Python’s Internals: Diving into CPython by implementing...

Talkat PyCon US 2022 · 2022-04-27..05-03· [python]
slides:none on file

Adds a real pipe operator to CPython by editing grammar and tokens, generating a new AST node in python.asdl, teaching the PEG parser how to emit it, changing the compiler to emit a BINARY_PIPE_CALL opcode, and extending the eval loop to call the function with the left value via the C API. Steps include regenerate the tokenizer (grammar/tokens → make regen), editing lib/opcode.py, recompiling CPython, and running tests. The prototype builds and runs, demonstrating source→AST→bytecode→execution.

AI-written summary · about

  1. 0:00Intro
  2. 0:53Sebastiaan Zeeff
  3. 3:53From source code to execution
  4. 4:26Adding a new binary operator: A pipe operator
  5. 7:19Tokenization: from raw text to a stream of tokens
  6. 8:36Tokenization: Add a token for the operator
  7. 11:06Python's Grammar & the PEG Parser
  8. 14:30Implementing our new grammar rule
  9. 19:20Regenerate the parser based on the new grammar
  10. 20:17Part 2: From Abstract Syntax Tree to Magic (Execution) Part 2
  11. 22:34Making the compiler use the new 'opcode File: Python/compilec
  12. 25:09Part 2: We've got Bytecode!
  13. 29:35Recap & Remarks
~/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.