Brandt Bucher – A JIT Compiler for CPython
encukou1 HN recommender · recommended in 1 month, 2023–2024
talk · advanced · 2023–2024 on HN
Brandt Bucher presents his prototype JIT compiler for CPython at the 2023 Core Developer Sprint. He explains the copy-and-patch approach, the implementation and its performance.
It is the go-to explanation of how CPython's JIT works and why its design is so simple.
Up next
4 mo on HNRSA ANIMATE: Language as a Window into Human Nature
Royal Society of Arts
2 HN recommender · 2011–2022
7 mo on HNWhy Are You So Angry? Part 1: A Short History of Anita Sarkeesian
Innuendo Studios
7 HN recommender · 2015–2022
6 mo on HNThe Marvel Symphonic Universe
Every Frame a Painting
6 HN recommender · 2017–2026
9 mo on HNConfessions of a Converted Lecturer: Eric Mazur
UMBCtube
9 HN recommender · 2009–2023
4 mo on HNInteractive notebooks ~ Pluto.jl | Fons van der Plas | JuliaCon 2020
The Julia Programming Language
6 HN recommender · 2020–2021
14 mo on HNA Better Default Colormap for Matplotlib | SciPy 2015 | Nathaniel Smith and Stéfan van der Walt
Enthought
15 HN recommender · 2015–2026
4 mo on HNGeoffrey West on COMPLEXITY
FQxI
3 HN recommender · 2014–2018
5 mo on HN4 2 1 Christopher Domas The future of RE Dynamic Binary Visualization
Adrian Crenshaw
7 HN recommender · 2013–2026
13 mo on HNRich Harris - Rethinking reactivity
You Gotta Love Frontend
15 HN recommender · 2019–2026
12 mo on HNLexical Scanning in Go - Rob Pike
GoogleFOSSSydney
13 HN recommender · 2012–2025
12 mo on HNWilliam Byrd on "The Most Beautiful Program Ever Written" [PWL NYC]
PapersWeLove
11 HN recommender · 2017–2026
10 mo on HNCppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”
CppCon
13 HN recommender · 2016–2024
3 comments from Hacker News
You're right, and in this case "foundational work" even undersells how minimal this work really is compared to the results it already gets. I recommend that people watch Brandt Bucher's "A JIT Compiler for CPython" from last year's CPython Core Developer Sprint[0]. It gives a good impression of the current implementation and its limitations, and some hints at what may or may not work out. It also indirectly gives a glimpse into the process of getting this into Python through the exchanges during the Q&A discussion. One thing to especially highlight is that this copy-and-patch has a much, much lower implementation complexity for the maintainers, as a lot of the heavy lifting is offloaded to LLVM. Case in point: as of the talk this was all just Brandt Bucher's work. The implementation at the time was ~700 lines of "complex" Python, ~100 lines of "complex" C, plus of course the LLVM dependency. This produces ~3000 lines of "simple" generated C, requires an additional ~300 lines of "simple" hand-written C to come together, and no further dependencies (so no LLVM necessary to run the JIT. Also "complex" and "simple" qualifiers are Bucher's terms, not mine). Another thing to note is that these initial performance improvements are just from getting this first version of the copy-and-patch JIT to work at all , without really doing any further fine-tuning or optimization. This may have changed a bit in the months since, but the situation is probably still comparable. So if one person
Yes. This is the algorithm chosen for the CPython JIT under development, scheduled for inclusion from 3.13 onwards. See ▶ this video
"Only 35% slower overall than LuaJIT" as per video from a month ago. No idea which kind of tests are these "overall" though. ▶ this video Slides (pg. 31 performance): link