It might be interesting to some to know that relatively recently (2016) PEP 523 ( https://www.python.org/dev/peps/pep-0523/ ) was created which provides a more efficient alternative to PyEval_SetTrace or PyEval_SetProfile for some use cases.
The idea of this PEP is to add frame evaluation into cPython. As the PEP says "For instance, it would not be difficult to implement a tracing or profiling function at the call level with this API"
The idea of this PEP is to add frame evaluation into cPython. As the PEP says "For instance, it would not be difficult to implement a tracing or profiling function at the call level with this API"
Elizaveta Shashkova (a PyCharm developer at JetBrains) gave a really good talk on the subject at this years PyCon ( https://www.youtube.com/watch?v=NdObDUbLjdg ).