Compiling Pythons with Custom Grammar for the sake of a joke
summary
Rewrites CPython’s grammar to replace the literal import token with AO, edits the grammar file and runs make, then runs a project-wide find-and-replace to change import sites; hits a bootstrap problem when the system Python doesn’t understand AO, solves it by compiling a two-token Python that accepts both import and AO, adding that interpreter to PATH and re-compiling so import becomes invalid and AO random works. Produces a runnable build called Nini, with extra hacked builtins (type → Slytherin, wingardium_leviosa) and it succeeds.
AI-written summary · about
chapters (9)
- 0:00Start
- 1:39What Is a Python Interpreter
- 3:21Import Statement
- 4:54What Is Compiling a Python Interpreter Mean
- 6:04Syntax Error
- 8:36Bootstrapping
- 11:54Bootstrap Compiling
- 16:09Overriding Built-In Functions
- 30:23Hacker School
related talks
36mHacking the Python AST
28mPipe-ifying Python: The how and why of interpreter hacking
30mDemystifying Python’s Internals: Diving into CPython by implementing...
31mDon't Do This
43m5 Years of Bad Ideas
28mHere be dragons: some elegant and ugly hacks in CPython
27mOh You Who Enter, Abandon All Hope
27mPython is Weird
