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

Don't import linecache at warnings toplevel #63578

Closed
pitrou opened this issue Oct 24, 2013 · 4 comments
Closed

Don't import linecache at warnings toplevel #63578

pitrou opened this issue Oct 24, 2013 · 4 comments
Labels
performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@pitrou
Copy link
Member

pitrou commented Oct 24, 2013

BPO 19379
Nosy @brettcannon, @pitrou, @tiran
Files
  • warnings_lazy.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 = None
    closed_at = <Date 2013-10-24.20:24:49.305>
    created_at = <Date 2013-10-24.20:09:10.495>
    labels = ['library', 'performance']
    title = "Don't import linecache at warnings toplevel"
    updated_at = <Date 2013-10-24.20:24:49.303>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2013-10-24.20:24:49.303>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-10-24.20:24:49.305>
    closer = 'python-dev'
    components = ['Library (Lib)']
    creation = <Date 2013-10-24.20:09:10.495>
    creator = 'pitrou'
    dependencies = []
    files = ['32340']
    hgrepos = []
    issue_num = 19379
    keywords = ['patch']
    message_count = 4.0
    messages = ['201174', '201178', '201179', '201182']
    nosy_count = 4.0
    nosy_names = ['brett.cannon', 'pitrou', 'christian.heimes', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue19379'
    versions = ['Python 3.4']

    @pitrou
    Copy link
    Member Author

    pitrou commented Oct 24, 2013

    Importing warnings pulls linecache at the top-level, while it's only necessary when printing warnings. The reason why it wasn't done lazily is obsolete, since Python now has per-module import locks. Attached patch makes the linecache imports lazy.

    This is desirable for issue bpo-19375.

    @pitrou pitrou added stdlib Python modules in the Lib dir performance Performance or resource usage labels Oct 24, 2013
    @tiran
    Copy link
    Member

    tiran commented Oct 24, 2013

    LGTM

    Good catch! :)

    @brettcannon
    Copy link
    Member

    LGTM

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 24, 2013

    New changeset 8939c0196990 by Antoine Pitrou in branch 'default':
    Close bpo-19379: Lazily import linecache in the warnings module, to make startup with warnings faster until a warning gets printed.
    http://hg.python.org/cpython/rev/8939c0196990

    @python-dev python-dev mannequin closed this as completed Oct 24, 2013
    @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
    performance Performance or resource usage stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants