Please, learn how to use `cython -a`. Simply cythonizing the Python source does not bring significant speed improvement. Here is a gist which should serve as a starting point: https://gist.github.com/ahojnnes/6450073

No guarantee, that this works as it should - I have not tested it.

Also integrate the other suggested changes (pos0, pos1 etc.)