If you can live with changing the signature from two tuples to just taking the four floats, you'll see a big further improvement --- these are the only lines showing up yellow when running the code through cython -a: <a href="https://rawgit.com/syllog1sm/a13542690c59d5e60ebf/raw/4994187cd560aab45dabe772a376171f409bd109/gistfile1.html" rel="nofollow">https://rawgit.com/syllog1sm/a13542690c59d5e60ebf/raw/499418...</a>
Looking at this step:<p><i>-from math import sin, cos, acos</i><p><i>+from libc.math cimport sin, cos, acos</i><p>What happens if the C math functions and the Python math functions don't take the same arguments/kinds of arguments?