Overview
Explore the dynamic nature of CPython and learn advanced hacking techniques in this 17-minute EuroPython Conference talk. Delve into the interpreter's internals step-by-step, from adding new syntax to modifying the evaluation loop. Discover how to manipulate AST, bytecode, CTypes, and the CPython evaluation loop. Gain insights into disassembling and reassembling bytecode, adding custom statements, and implementing runtime syntax modifications. Cover topics such as lexing, parsing, AST manipulation, bytecode generation, and evaluation. Learn practical hacks like modifying tokens, creating custom decode functions, implementing PEPs, and optimizing code execution. Uncover the potential for extending Python's capabilities through advanced interpreter manipulation techniques.
Syllabus
Intro
Lexing - Tokenization
Parsing - Parser
AST (where actual hack begins)
Bytecode Generation
Evaluation
Walrus on Python 3.7
The Strategy For Hacking
Modifiying the Tokens
Modifying The Source
Creating decode function for Encoding
Adding a search function
Implementing Peps (Example PEP313)
Scoping
Runtime
Rusty Return
Transforming AST (2)
Poophole Optimizer
Optimize Function
Optimizers 2 (Example Elem Local Vars)
Catlizor v1-extended
Hooking
Taught by
EuroPython Conference