This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bbayles
Recipients bbayles, cheryl.sabella, docs@python, eric.araujo, ezio.melotti, pitrou, willingc
Date 2018-02-25.13:50:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519566657.99.0.467229070634.issue32017@psf.upfronthosting.co.za>
In-reply-to
Content
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 [1] 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 ([2]) to take advantage of CPython's "low-level support for attaching profiling and execution tracing facilities" ([3]). 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 [4].


[1] https://docs.python.org/3/library/profile.html#profile.Profile
[2] https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Modules/_lsprof.c#L693
[3] https://docs.python.org/3/c-api/init.html#profiling-and-tracing
[4] https://docs.python.org/3/library/profile.html#using-a-custom-timer
History
Date User Action Args
2018-02-25 13:50:58bbaylessetrecipients: + bbayles, pitrou, ezio.melotti, eric.araujo, docs@python, willingc, cheryl.sabella
2018-02-25 13:50:57bbaylessetmessageid: <1519566657.99.0.467229070634.issue32017@psf.upfronthosting.co.za>
2018-02-25 13:50:57bbayleslinkissue32017 messages
2018-02-25 13:50:57bbaylescreate