How to profile cython functions line-by-line
问题 I often struggle to find bottlenecks in my cython code. How can I profile cython functions line-by-line? 回答1: Robert Bradshaw helped me to get Robert Kern's line_profiler tool working for cdef functions and I thought I'd share the results on stackoverflow . In short, set up a regular .pyx file and build script and add the following before your call to cythonize . from Cython.Compiler.Options import directive_defaults directive_defaults['linetrace'] = True directive_defaults['binding'] = True