Best afterAliasing: two names, one list

Sorting into two piles

Walk down a row of numbers and drop each one onto the evens pile or the odds pile. Easy — until the way you make the two piles quietly makes them the same pile. Step the buggy version and watch every number land on both piles at once.

Sort the numbers into two piles: evens in one pile, odds in the other.

Sorting into two piles — the aliasing trap execution-derived · CPython
6    else:
same data, two zoom levels
state after line 1 runs
nums
3852
Evens
empty
Odds
empty

noteOur numbers: 3, 8, 5, 2. We want evens in one pile and odds in the other.

step 1 / 15

Click a line, drag the slider, or use the keys.

What you are looking at

Four numbers — 3, 8, 5, 2 — and two piles. Each number is even or odd, so it belongs in exactly one pile. The loop visits them one at a time (the current number is n) and appends it to the right pile.

Try clicking the for line repeatedly to walk one iteration at a time. Every pile you see came from running the program under CPython's tracer — see how GlassBox stays honest.