using the M_PI constant imported from libc.math allows cython to transform this line into pure c code (I've just run your code through "cython -a" to check which parts were not translated to pure C, to see whether some additional performance gain is possible)