python equivalent of main.lua -- for testing speed and correctness