Automatically Translating Python Source to Idiomatic Go Code
summary
A Go program parses Python into an AST, performs whole-program type inference and propagation, and emits formatted Go code via gofmt; it converts several thousand lines of dynamically typed Python into idiomatic, fully typed Go code and handles examples like fizzbuzz, classes and quicksort. The approach requires forbidding dynamic imports and runtime monkeypatching, and produces roughly 90–95% correct output that is hand-finished for production.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:01Andre Eriksson
- 2:42Welcome
- 3:35Story
- 4:58Why Go
- 6:34Why Python
- 7:32Master Plan
- 8:13Escape hatch
- 9:26Approach
- 10:13Python Syntax Tree
- 11:23Python Whole Program Analysis
- 12:27Python Example
- 14:35Type Inference
- 16:08Type Propagation
- 17:41Live Demo
- 23:42Conclusion
- 24:19Questions
related talks
39mIs Go A Good Language to Build Compilers?
27mDigging into Abstract Syntax Trees for analyzing and modifying Python programs
27mInception: Go programs that generate Go code
22mGenerating Generators
01h 00mHow to write a programming language and shell in Go with 92% test coverage and instant CI/CD
30mLet's talk about transpilers!
43mUnderstanding the Go Compiler
27mOh You Who Enter, Abandon All Hope
