Solving a recent Advent of Code problem, I found my default Python was ~40x slower than PyPy. I was able to get that down to about 17x with this code by limiting calls to
You can improve small things, but pypy will (most likely) always be faster in this task.
For both CPython and Cython:
For Cython:
int
s and the commands as an array of int
s to skip most type checks.