Colliding galaxies

Python on the GPU · Fun & games

Two discs fall into each other. Every body pulls on every other: accel() is a Python function, compiled to a WebGPU compute shader with one invocation per body. Drag to pan, scroll or pinch to zoom.

3×
t = 0.0– fps
checking GPU against CPython…
Each substep runs accel() over every pair of bodies, then drift(). Colour is speed: blue slow, gold fast.