cython version of moments