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

Remove unused constants from optimized code objects #46745

Closed
abalkin opened this issue Mar 26, 2008 · 3 comments
Closed

Remove unused constants from optimized code objects #46745

abalkin opened this issue Mar 26, 2008 · 3 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@abalkin
Copy link
Member

abalkin commented Mar 26, 2008

BPO 2493
Nosy @rhettinger, @abalkin
Files
  • compress-consts.diff: Patch against revision 61948
  • compress-consts-1.diff: Patch against revision 61948
  • 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/rhettinger'
    closed_at = <Date 2008-06-12.22:08:50.084>
    created_at = <Date 2008-03-26.14:47:35.009>
    labels = ['interpreter-core', 'performance']
    title = 'Remove unused constants from optimized code objects'
    updated_at = <Date 2008-06-12.22:08:50.062>
    user = 'https://github.com/abalkin'

    bugs.python.org fields:

    activity = <Date 2008-06-12.22:08:50.062>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2008-06-12.22:08:50.084>
    closer = 'rhettinger'
    components = ['Interpreter Core']
    creation = <Date 2008-03-26.14:47:35.009>
    creator = 'belopolsky'
    dependencies = []
    files = ['9867', '9868']
    hgrepos = []
    issue_num = 2493
    keywords = ['patch']
    message_count = 3.0
    messages = ['64558', '64561', '68101']
    nosy_count = 2.0
    nosy_names = ['rhettinger', 'belopolsky']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = None
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue2493'
    versions = ['Python 2.6']

    @abalkin
    Copy link
    Member Author

    abalkin commented Mar 26, 2008

    When peephole optimizer folds multiple constants into one, the old
    constants remain in co_consts. Attached patch removes such unused
    constants.

    @abalkin abalkin added interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage labels Mar 26, 2008
    @rhettinger rhettinger self-assigned this Mar 26, 2008
    @abalkin
    Copy link
    Member Author

    abalkin commented Mar 26, 2008

    I've noticed that the original patch does not handle the error condition
    from failed consts resize correctly. Please see compress-consts-1.diff
    for a fix.

    @rhettinger
    Copy link
    Contributor

    The issue with unused constants is an artifact of the peepholer running
    after the bytecode generation phase. When constant folding was
    written, I intentionally left-out a step to remove unused constants
    because of the code complexity, the fragility of the process, because
    the benefits were inconsequential, and because it added to compilation
    time.

    It would be better to wait for the AST optimizer to replace the
    peepholer. AST optimizations are upstream from bytecode generation, so
    the unused constant issue simply disappears.

    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants