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

Add sys.isinterned() #78573

Closed
serhiy-storchaka opened this issue Aug 13, 2018 · 5 comments
Closed

Add sys.isinterned() #78573

serhiy-storchaka opened this issue Aug 13, 2018 · 5 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 34392
Nosy @warsaw, @brettcannon, @rhettinger, @ronaldoussoren, @tiran, @serhiy-storchaka
PRs
  • bpo-34392: Add sys. _is_interned() #8755
  • 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 = None
    created_at = <Date 2018-08-13.10:24:33.256>
    labels = ['interpreter-core', 'type-feature', '3.8']
    title = 'Add sys.isinterned()'
    updated_at = <Date 2018-08-19.06:55:15.282>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-08-19.06:55:15.282>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2018-08-13.10:24:33.256>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34392
    keywords = ['patch']
    message_count = 5.0
    messages = ['323473', '323474', '323539', '323545', '323744']
    nosy_count = 6.0
    nosy_names = ['barry', 'brett.cannon', 'rhettinger', 'ronaldoussoren', 'christian.heimes', 'serhiy.storchaka']
    pr_nums = ['8755']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue34392'
    versions = ['Python 3.8']

    @serhiy-storchaka
    Copy link
    Member Author

    I need to test whether the string is interned for Python implementations of marshal.dumps(). It is easy to do in C, and I suggest to expose this functionality to Python.

    Currently you can test if the string is interned using the following function:

        def isinterned(s):
            return sys.intern(s) is s

    But it has a side effect -- it interns a string if it is not equal to an already interned string.

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Aug 13, 2018
    @tiran
    Copy link
    Member

    tiran commented Aug 13, 2018

    I'd prefer to have this as an internal API, either sys._isinterned() or as a helper method in testcapi.

    @brettcannon
    Copy link
    Member

    I agree with Christian; this is an implementation detail so it should be flagged as private/internal somehow.

    @warsaw
    Copy link
    Member

    warsaw commented Aug 15, 2018

    Agreed it should be non-public, but can we please call it sys._is_interned()?

    @serhiy-storchaka
    Copy link
    Member Author

    Thank you all for the feedback. The function is renamed to sys._is_interned() and documented as optional.

    @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

    4 participants