Profiling in Python: Who called the function?

后端 未结 8 1826
执念已碎
执念已碎 2020-12-22 15:17

I\'m profiling in Python using cProfile. I found a function that takes a lot of CPU time. How do I find out which function is calling this heavy function the mo

相关标签:
8条回答
  • 2020-12-22 16:16

    inspect.stack() will give you the current caller stack.

    0 讨论(0)
  • 2020-12-22 16:17

    Pycscope does this. I just found it today, so I can't speak to how good it is, but the few examples I've tried have been pretty good (though not perfect).

    https://pypi.python.org/pypi/pycscope/

    You would use this to generate a cscope file and then a cscope plugin from an editor, VIM specifically. I tried using it with vanilla cscope, it seems that plain cscope gets confused.

    0 讨论(0)
提交回复
热议问题