Here be dragons: some elegant and ugly hacks in CPython
summary
CPython history shows concrete hacks: a SyntaxError constructor inspects the parser text and emits a specific message for Python 2 style print missing parentheses (landed around 3.4.2) after an experimental implicit calls patch proved the idea; functools.wraps originally copies dunder attributes in a brute‑force loop that works well enough for seven years until a proper proxy appears; collections.namedtuple builds classes by executing a string templating class definition; small REPL affordances come from the site module. These fixes are pragmatic, documented, and mostly effective.
AI-written summary · about
chapters (9)
- 0:00Intro
- 0:28Why isn't all code beautiful?
- 4:14Customising Syntax Errors (Demo)
- 10:15Buying time with "80% solutions"
- 14:20Decorators and wrapper functions (Demo)
- 17:11Let me out! (Demo)
- 19:46Use simple components
- 21:19Implementing a type factory (Demo)
- 26:27Keep technical debt under control!








