Closed
Description
current scenario -
- if one wants to profile the c functions that are called when running python code, then it is either not possible, or not well documented.
- in the documentation it specifies,
https://docs.python.org/dev/using/configure.html#cmdoption-enable-profiling
https://docs.python.org/dev/using/configure.html#cmdoption-with-valgrind
but there is no example how to use them (assuming they can be used to profile c functions while running python code)
- related discussions,
https://stackoverflow.com/questions/375913/how-can-i-profile-c-code-running-on-linux/378024#378024
https://discuss.python.org/t/easier-way-to-look-into-the-cpython-implementation/15247/8
but there appears to be no way to profile c functions while running python code.
- one can get the backtrace but it requires to use an external debugger like
lldb
orgdb
.
expected scenario -
- if this is already possible then add an example to the documentation page
- if not then, there could be a build option to display the backtrace, profiling of the c functions, like,
./configure --with-backtrace --with-c-profiling
- ideally one would want something like this when running python in the console,
>>> x = 1
with backtrace enabled,
backtrace
function_1 at file_1.c
function_2 at file_2.c
function_3 at file_1.c
function_1 at file_1.c
with profiling enabled,
file_name total number of times called total time
function_1 at file_1.c n1 t1 sec
function_2 at file_2.c n2 t2 sec
- no use of external debugger for this, one would want to do this while running python in the console.