[docs] [issue25726] sys.setprofile / sys.getprofile asymetry

Georg Brandl report at bugs.python.org
Sat Feb 13 06:58:36 EST 2016


Georg Brandl added the comment:

Ok, this is because internally, sys.setprofile (or to be exact, PyEval_SetProfile) sets two things: a C function, and a "profileobj", which is the argument to setprofile().

sys.setprofile sets the C function to the "profile_trampoline", which supports calling Python profile functions.  The profileobj is the Python profile function.

The C profiler sets the C function to a different callback, and uses the profileobj for storing the reference to the Profiler object.

sys.getprofile just returns the profileobj, which means that you can't save/restore the profiler state with the two functions when using cProfile.

There is not much we can do here except for explicitly documenting this.

----------
assignee:  -> docs at python
components: +Documentation
nosy: +docs at python

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25726>
_______________________________________


More information about the docs mailing list