Uncovering the magic of implementing a new Python syntax feature
summary
PEP 750 T-strings are implemented in CPython end-to-end: the handwritten tokenizer recognizes t-string-start / t-string-middle / t-string-end tokens, the generated parser uses grammar actions and memo flags to emit AST nodes like TemplateString → Interpolation(Name id, Constant), the bytecode compiler emits instructions such as load_const, load_name, build_interpolation and build_template bytecode, and the stack‑based interpreter executes them. The implementation runs in Python 3.14, includes a simple optimization collapsing two load_consts + build_tuple into one load_const tuple, and produces the new template type correctly.
AI-written summary · about
chapters (8)
- 0:00Introduction and speaker background
- 1:44What are T-strings
- 5:20Syntax features in Python
- 7:54Tokenizer and token stream
- 11:34Parser and AST construction
- 19:00Bytecode compiler process
- 24:02Python interpreter execution
- 27:48Recap and Q&A
related talks
31mPEP 750 - T-strings: safer and smarter string processing
27m"Disentangling formatted strings with T-strings"
28mIntroducing t-strings: f-strings with superpowers
35mText Is Not Text: The History of Strings in Python
20mPEP 498: The Monologue
15mExploring the Latest Features of Python 3.12
03h 40mTyping
24mF Strings!
