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@python components: +Documentation nosy: +docs@python _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25726> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com