cython

profile=True not working on my machine, but is working in google colab


I am trying to get profile=True and %%prun to give a profile of the runtime for the compiled cython program. But on my Windows machine it is not working, the same code works on google colab. Cython version 3.0.12.

Is my c++ compiler to blame?


Solution

  • In Python 3.12, they changed profiling to use a new system. The upshot is that profiling doesn't work on Python 3.12 on any version of Cython.

    In Python 3.13 they added a C API for this new system. Cython 3.1 supports this C API but Cython 3.0 doesn't (just because it was added after the release of Cython 3.0).

    So the upshot is: if you're trying to profile on Python 3.13+, then you need to be using Cython 3.1. If you need to use Cython 3.0 then profiling only works on Python 3.11 and lower.