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

TracebackException saves more data than it needs for format #87043

Closed
iritkatriel opened this issue Jan 9, 2021 · 4 comments
Closed

TracebackException saves more data than it needs for format #87043

iritkatriel opened this issue Jan 9, 2021 · 4 comments
Labels
3.10 only security fixes performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@iritkatriel
Copy link
Member

BPO 42877
Nosy @gvanrossum, @iritkatriel
PRs
  • bpo-42877: add the 'compact' param to TracebackException's __init__ #24179
  • 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 = None
    closed_at = <Date 2021-01-15.02:46:07.473>
    created_at = <Date 2021-01-09.19:11:00.250>
    labels = ['library', '3.10', 'performance']
    title = 'TracebackException saves more data than it needs for format'
    updated_at = <Date 2021-01-15.02:46:07.472>
    user = 'https://github.com/iritkatriel'

    bugs.python.org fields:

    activity = <Date 2021-01-15.02:46:07.472>
    actor = 'gvanrossum'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-01-15.02:46:07.473>
    closer = 'gvanrossum'
    components = ['Library (Lib)']
    creation = <Date 2021-01-09.19:11:00.250>
    creator = 'iritkatriel'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42877
    keywords = ['patch']
    message_count = 4.0
    messages = ['384738', '385082', '385096', '385097']
    nosy_count = 2.0
    nosy_names = ['gvanrossum', 'iritkatriel']
    pr_nums = ['24179']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue42877'
    versions = ['Python 3.10']

    @iritkatriel
    Copy link
    Member Author

    TracebackException saves both __cause__ and __context__ even though format() ignores the __context__ if there is __cause__.

    If we change the constructor to save only what format() needs, it will save space and simplify the code.

    @iritkatriel iritkatriel added 3.10 only security fixes stdlib Python modules in the Lib dir performance Performance or resource usage labels Jan 9, 2021
    @iritkatriel iritkatriel changed the title TracebackException saves more data than it needs TracebackException saves more data than it needs for format Jan 13, 2021
    @iritkatriel iritkatriel changed the title TracebackException saves more data than it needs TracebackException saves more data than it needs for format Jan 13, 2021
    @iritkatriel
    Copy link
    Member Author

    As discussed on the PR: Since __context__ is documented, we can't just optimize it away. Instead we add a new param "compact", defaulted to False, which controls whether this optimization should be applied.

    Module level functions in traceback pass True since they don't access __context__ directly.

    @gvanrossum
    Copy link
    Member

    New changeset 4c94d74 by Irit Katriel in branch 'master':
    bpo-42877: add the 'compact' param to TracebackException's __init__ (bpo-24179)
    4c94d74

    @gvanrossum
    Copy link
    Member

    Thanks!

    @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
    3.10 only security fixes performance Performance or resource usage stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants