[docs] [issue32017] profile.Profile() has no method enable()
report at bugs.python.org
Sun Feb 25 08:50:58 EST 2018
bbayles <bbayles at gmail.com> added the comment:
I'm afraid that profile.Profile and cProfile.Profile behave pretty differently, and there's not a good way to bring the methods from the C version to the Python version.
The example at  shows a cProfile.Profile object being instantiated and enabled. At this point the profiler is tracing execution - until the disable() method is called, any activity is recorded.
profile.Profile doesn't work this way. Creating a profile.Profile object doesn't cause activity to be recorded. It doesn't do anything until you call one of its run* methods.
This is because the C version uses PyEval_SetProfile () to take advantage of CPython's "low-level support for attaching profiling and execution tracing facilities" (). I don't think we can do that from the Python version.
There is already a precedent for showing differences between cProfile.Profile and profile.Profile in the existing docs - see .
Python tracker <report at bugs.python.org>
More information about the docs