PERF: cythonized parts of to_csv for increased perf
PERF: more cython tweaks
PERF: cythonize improved python version