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.

classification
Title: Unify trace and profile interfaces
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: belopolsky Nosy List: Gordon C, belopolsky, georg.brandl
Priority: normal Keywords: patch

Created on 2010-09-24 16:57 by belopolsky, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
9941.patch Gordon C, 2015-11-21 20:19 review
Messages (5)
msg117309 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-09-24 16:57
The trace and profile modules provide similar functionality, but have some gratuitous differences in their APIs and command line interfaces.

For example, the method to trace a single call is Trace.runfunc, but almost identical Profile method is called "runcall".

The CLIs provided by the two modules are vastly different: profile splits out formatting of the results into a separate module, pstats, while trace module includes many options to control the output of traced runs.

This situation leeds to an unnecessary burden on users who need to learn two different ways to do very similar things.
msg117311 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-09-24 17:01
The runfunc/runcall difference is the easiest to address.  I propose to add runcall to Trace as an alias to runfunc and deprecate runfunc.  In addition, I propose to add __enter__ and __exit__ methods to both Trace and Profile so that they can be used as context managers.
msg117352 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-09-25 10:23
Sounds good to me.
msg117451 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-09-27 17:26
I've ran into a problem adding context manager functionality to Profile/Trace objects.  When profile/trace function is set in __enter__ and removed in __exit__ it catches two spurious events: a return from __enter__ and a call to __exit__.  This is particularly problematic with Profile which is not prepared to handle a return event that does not follow a matching call.
msg255069 - (view) Author: Gordon C (Gordon C) * Date: 2015-11-21 20:19
I know this is an old bug (my first-time contribution), but I checked and it still applies in current versions. As suggested by @belopolsky, I added runcall to Trace and made runfunc an alias for it. I also updated the tests for trace to reflect the change to runcall over runfunc.
History
Date User Action Args
2022-04-11 14:57:06adminsetgithub: 54150
2015-11-21 20:19:30Gordon Csetfiles: + 9941.patch

nosy: + Gordon C
messages: + msg255069

keywords: + patch
2011-01-12 16:21:34belopolskysetversions: + Python 3.3, - Python 3.2
2010-09-27 17:26:14belopolskysetmessages: + msg117451
2010-09-25 10:23:14georg.brandlsetnosy: + georg.brandl
messages: + msg117352
2010-09-24 17:01:16belopolskysetmessages: + msg117311
2010-09-24 16:57:45belopolskycreate