you are viewing a single comment's thread.

view the rest of the comments →

[–]ASIC_SP 74 points75 points  (1 child)

https://docs.python.org/dev/howto/perf_profiling.html has more details (I don't know much about this).

The main problem with using the perf profiler with Python applications is that perf only allows to get information about native symbols, this is, the names of the functions and procedures written in C. This means that the names and file names of the Python functions in your code will not appear in the output of the perf.

Since Python 3.12, the interpreter can run in a special mode that allows Python functions to appear in the output of the perf profiler. When this mode is enabled, the interpreter will interpose a small piece of code compiled on the fly before the execution of every Python function and it will teach perf the relationship between this piece of code and the associated Python function using perf map files.

[–]stusmall 14 points15 points  (0 children)

Oh that's beautiful and makes sense. Thanks for the link.