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

Speed up import from non-packages #77127

Closed
serhiy-storchaka opened this issue Feb 25, 2018 · 2 comments
Closed

Speed up import from non-packages #77127

serhiy-storchaka opened this issue Feb 25, 2018 · 2 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@serhiy-storchaka
Copy link
Member

BPO 32946
Nosy @brettcannon, @ncoghlan, @ericsnowcurrently, @serhiy-storchaka
PRs
  • bpo-32946: Speed up "from ... import ..." from non-packages. #5873
  • 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 2018-03-11.08:58:13.761>
    created_at = <Date 2018-02-25.08:46:54.819>
    labels = ['interpreter-core', '3.8', 'performance']
    title = 'Speed up import from non-packages'
    updated_at = <Date 2018-03-11.08:58:13.760>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-03-11.08:58:13.760>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-03-11.08:58:13.761>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2018-02-25.08:46:54.819>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32946
    keywords = ['patch']
    message_count = 2.0
    messages = ['312781', '313587']
    nosy_count = 4.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'eric.snow', 'serhiy.storchaka']
    pr_nums = ['5873']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue32946'
    versions = ['Python 3.8']

    @serhiy-storchaka
    Copy link
    Member Author

    The proposed PR optimizes "from ... import ..." from non-package modules.

    $ ./python -m perf timeit 'from locale import getlocale'
    Unpatched:  Mean +- std dev: 811 ns +- 27 ns
    Patched:    Mean +- std dev: 624 ns +- 17 ns

    Currently _bootstrap._handle_fromlist() is called which does nothing if the module is not a package, but adds an overhead of calling a Python function. The PR moves this check out of _handle_fromlist and avoid calling it if not needed.

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage labels Feb 25, 2018
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 4e24425 by Serhiy Storchaka in branch 'master':
    bpo-32946: Speed up "from ... import ..." from non-packages. (GH-5873)
    4e24425

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

    No branches or pull requests

    1 participant