A Python Interpreter Written in Python

https://aosabook.org/en/500L/a-python-interpreter-written-in-python.html

Article

  • A bytecode interpreter for Python, written in Python — ~500 lines
  • Implements a stack-based virtual machine executing CPython bytecode
  • Part of the 500 Lines or Less AOSA book project

Discussion

  • Commenters highlight the elegant getattr dispatch trick as worth studying for real interpreters
  • Clarified it’s a bytecode interpreter, not a full parser — skips tokenizing/parsing
  • Related projects byterun and x-python mentioned; metacircular interpreter comparisons made

Discuss on HN


Type Link
Added Apr 17, 2026
Modified Apr 17, 2026