A Python Interpreter Written in Python (2016)
Report a link problem
The originally submitted URL now redirects to the address above. Updating the destination does not change the item’s HN history, Hall membership, or rank.
Submission timeline
2007–2026One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.
First comments on top threads
HN comment orderI found this code very useful. I've been spelunking in CPython and mostly I understand it, and can find my way around. But ceval.c is another beast entirely, being full of macros and gotos, not to mention being 5000 lines long. The interpreter loop starts here: https://github.com/python/cpython/blob/master/Python/ceval.c... So I appreciate seeing the algorithm laid out in Python. In particular it clarifies that there are three separate stacks: 1. call stack 2. block stack for try/except, loops, etc. 3. value stack…
> Byterun is a Python interpreter written in Python. This may strike you as odd, but it's no more odd than writing a C compiler in C. I'm not so sure. The difference between a self-hosted compiler and a circular interpreter is that the compiler has a binary artifact that you can store. With an interpreter, you still need some binary to run your interpreter, which will probably be CPython, making the new interpreter redundant. And if you add a…
What an excellent 500 lines introduction to the byterun bytecode interpreter / virtual machine: https://github.com/nedbat/byterun Also, proceeds from optional purchases of the AOSA books go to Amnesty International. https://aosabook.org/
The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.
- Breakout years
- 2
- Total points
- 353
- Total comments
- 96
100+ points or 50+ comments
reference only — not used in Hall rules or ranking
reference only — not used in Hall rules or ranking
Every submission
| Date | Title as submitted | By | Points | Comments |
|---|---|---|---|---|
| 2015-11-26 | 500 Lines or Less – A Python Interpreter Written in Python | leephillips | 3 | 0 |
| 2016-04-16 | A Python Interpreter Written in Python | 0xmohit | 3 | 0 |
| 2017-04-11 | A Python Interpreter Written in Python | cristoperb | 4 | 0 |
| 2018-04-09 | A Python Interpreter Written in Python (2016)First breakout · Best thread | jstrieb | 181 | 41 |
| 2019-09-21 | A Python Interpreter Written in Python | nnnmnten | 2 | 1 |
| 2024-02-18 | A Python Interpreter in 500 lines of Python | tosh | 3 | 0 |
| 2026-04-13 | A Python Interpreter Written in PythonLatest 20+ point return | xk3 | 157 | 54 |