porting this thing to python.

so far yields a ~400% speed increase