HN Hall of Fame Weekly email

A function decorator that rewrites the bytecode to enable goto in Python

github.com Software & code Software projects Software engineering Candidate
Screenshot of github.com captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 3 calendar years, with breakout response in 2 of them.

submissions
3
submitters
3
observed span
2015–2021
peak thread · 88 comments
197 pts
latest 20+ return · 2021-09-21
197 pts

Submission timeline

2007–2026

One 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 order

Along the lines of rewriting bytecode at runtime, https://www.python.org/dev/peps/pep-0302/ lets you arbitrarily hook Python's import process and rewrite .pyc files as desired. As a practical application, pytest uses this to take the statement `assert foo == bar` and rewrite the AST into a number of instructions that extract the values of foo and bar and print them if the assertion fails: http://pybites.blogspot.com/2011/07/behind-scenes-of-pytests... (https://docs.pytest.org/en/6.2.x/assert.html for those…

btown·197-point thread·

Hey, awesome! And it produces a true goto as well, working on the bytecode level. I wonder if there's a way to remove the extra nops? This is really, really useful for doing language-to-language translation. Without the ability to arbitrarily branch from basic block to basic block, it's possible for the basic block graph produced by a program in one language to be simply inexpressible in your target language. You end up having to fake it with a while loop…

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

100+ points or 50+ comments

Total points
370

reference only — not used in Hall rules or ranking

Total comments
131

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2015-09-21Goto in PythonFirst breakoutwallunit17043
2020-06-25Python-goto: A function decorator that implements goto by rewriteing bytecodesegfaultbuserr30
2021-09-21A function decorator that rewrites the bytecode to enable goto in PythonBest thread · Latest 20+ point returnsea6ear19788