As with others, absolutely: raycasting is going to be slow. It's slow even in C, and that's kinda the reason GPUs were invented. As far as optimization, often people set up 2D arrays laid out in memory with x as the second variable. So, although this might not be possible with NumPy, if you can order your array accesses as arr[y][x], you might get better cache coherency.