Optimize statistics via Cython module.