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

Optimize out __debug__ at the AST level #76553

Closed
serhiy-storchaka opened this issue Dec 19, 2017 · 2 comments
Closed

Optimize out __debug__ at the AST level #76553

serhiy-storchaka opened this issue Dec 19, 2017 · 2 comments
Assignees
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 32372
Nosy @rhettinger, @pitrou, @methane, @serhiy-storchaka
PRs
  • bpo-32372: Move __debug__ optimization to the AST level. #4925
  • 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/serhiy-storchaka'
    closed_at = <Date 2017-12-25.10:48:57.560>
    created_at = <Date 2017-12-19.14:11:45.504>
    labels = ['interpreter-core', 'type-feature', '3.7']
    title = 'Optimize out __debug__ at the AST level'
    updated_at = <Date 2017-12-25.10:48:57.560>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-12-25.10:48:57.560>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-12-25.10:48:57.560>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2017-12-19.14:11:45.504>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32372
    keywords = ['patch']
    message_count = 2.0
    messages = ['308643', '309035']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'pitrou', 'methane', 'serhiy.storchaka']
    pr_nums = ['4925']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32372'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    __debug__ is substituted by the constant value at the code generation stage (see bpo-27169). This prevents it from participating in constant folding at the AST level. The proposed patch moves this optimization to the AST level. This will lead to optimizing "if not __debug__" and will allow to add more optimizations at the AST level (like optimizing expressions "a if __debug__ else b" and "__debug__ and a").

    @serhiy-storchaka serhiy-storchaka added the 3.7 (EOL) end of life label Dec 19, 2017
    @serhiy-storchaka serhiy-storchaka self-assigned this Dec 19, 2017
    @serhiy-storchaka serhiy-storchaka added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Dec 19, 2017
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 3dfbaf5 by Serhiy Storchaka in branch 'master':
    bpo-32372: Move __debug__ optimization to the AST level. (bpo-4925)
    3dfbaf5

    @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.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant