How to profile cython functions line-by-line

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. # Thanks to @tryptofame for proposing an updated snippet from Cython.Compiler.Options import … Read more

Idiomatic way to do list/dict in Cython?

Cython now has template support, and comes with declarations for some of the STL containers. See http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html#standard-library Here’s the example they give: from libcpp.vector cimport vector cdef vector[int] vect cdef int i for i in range(10): vect.push_back(i) for i in range(10): print vect[i]

Compile Cython Extensions Error – Pycharm IDE [duplicate]

JetBrains has provided an answer: https://www.jetbrains.com/help/pycharm/2017.3/cython-speedups.html If you’re on Ubuntu, run: For Python 2.7: sudo apt-get install python-dev For Python 3.5: sudo apt-get install python3-dev For Python 3.6: sudo apt-get install python3.6-dev For Python 3.7: sudo apt-get install python3.7-dev

tech