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

tags for anonymous code objects should be interned #77451

Closed
dmoisset mannequin opened this issue Apr 12, 2018 · 4 comments
Closed

tags for anonymous code objects should be interned #77451

dmoisset mannequin opened this issue Apr 12, 2018 · 4 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@dmoisset
Copy link
Mannequin

dmoisset mannequin commented Apr 12, 2018

BPO 33270
Nosy @rhettinger, @serhiy-storchaka, @dmoisset
PRs
  • bpo-33270: Intern names for all anonymous code objects #6472
  • 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-04-15.22:13:46.265>
    created_at = <Date 2018-04-12.20:32:14.261>
    labels = ['interpreter-core', 'type-feature', '3.8']
    title = 'tags for anonymous code objects should be interned'
    updated_at = <Date 2018-04-15.22:13:46.264>
    user = 'https://github.com/dmoisset'

    bugs.python.org fields:

    activity = <Date 2018-04-15.22:13:46.264>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-04-15.22:13:46.265>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2018-04-12.20:32:14.261>
    creator = 'Daniel Moisset'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33270
    keywords = ['patch']
    message_count = 4.0
    messages = ['315232', '315263', '315345', '315346']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'serhiy.storchaka', 'Daniel Moisset']
    pr_nums = ['6472']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue33270'
    versions = ['Python 3.8']

    @dmoisset
    Copy link
    Mannequin Author

    dmoisset mannequin commented Apr 12, 2018

    In compile.c, some strings are created to be used as name of anonymous code objects: "<module>", "<lambda>", "<genexpr>", "<listcomp>", "<setcomp>" and "<dictcomp>".

    Only the first two of those are interned (created with PyUnicode_InternFromString ), the rest are created with "PyUnicode_FromString". Even if they use a static variable to avoid creating multiple instances, not interning results in multiple copies when code objects are marshaled into pyc files and reloaded (one copy per module).

    Always using PyUnicode_InternFromString should be more consistent, and slightly more efficient

    @dmoisset dmoisset mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Apr 12, 2018
    @brettcannon brettcannon added 3.8 only security fixes type-feature A feature request or enhancement labels Apr 13, 2018
    @rhettinger
    Copy link
    Contributor

    +1

    @serhiy-storchaka
    Copy link
    Member

    New changeset f303639 by Serhiy Storchaka (Zackery Spytz) in branch 'master':
    bpo-33270: Intern names for all anonymous code objects (bpo-6472)
    f303639

    @serhiy-storchaka
    Copy link
    Member

    Thank you for your contribution Zackery.

    @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) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants