Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify trace and profile interfaces #54150

Open
abalkin opened this issue Sep 24, 2010 · 5 comments
Open

Unify trace and profile interfaces #54150

abalkin opened this issue Sep 24, 2010 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@abalkin
Copy link
Member

abalkin commented Sep 24, 2010

BPO 9941
Nosy @birkenfeld, @abalkin
Files
  • 9941.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/abalkin'
    closed_at = None
    created_at = <Date 2010-09-24.16:57:45.294>
    labels = ['type-feature', 'library']
    title = 'Unify trace and profile interfaces'
    updated_at = <Date 2015-11-21.20:19:30.979>
    user = 'https://github.com/abalkin'

    bugs.python.org fields:

    activity = <Date 2015-11-21.20:19:30.979>
    actor = 'Gordon C'
    assignee = 'belopolsky'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2010-09-24.16:57:45.294>
    creator = 'belopolsky'
    dependencies = []
    files = ['41116']
    hgrepos = []
    issue_num = 9941
    keywords = ['patch']
    message_count = 5.0
    messages = ['117309', '117311', '117352', '117451', '255069']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'belopolsky', 'Gordon C']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue9941'
    versions = ['Python 3.3']

    @abalkin
    Copy link
    Member Author

    abalkin commented Sep 24, 2010

    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.

    @abalkin abalkin self-assigned this Sep 24, 2010
    @abalkin abalkin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Sep 24, 2010
    @abalkin
    Copy link
    Member Author

    abalkin commented Sep 24, 2010

    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.

    @birkenfeld
    Copy link
    Member

    Sounds good to me.

    @abalkin
    Copy link
    Member Author

    abalkin commented Sep 27, 2010

    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.

    @GordonC
    Copy link
    Mannequin

    GordonC mannequin commented Nov 21, 2015

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants