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

Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() #75046

Closed
serhiy-storchaka opened this issue Jul 6, 2017 · 5 comments
Closed
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage topic-unicode

Comments

@serhiy-storchaka
Copy link
Member

BPO 30863
Nosy @vstinner, @ezio-melotti, @serhiy-storchaka
PRs
  • bpo-30863: Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). #2599
  • 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-10-23.20:03:17.257>
    created_at = <Date 2017-07-06.07:53:21.848>
    labels = ['interpreter-core', '3.8', 'expert-unicode', 'performance']
    title = 'Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString()'
    updated_at = <Date 2018-10-23.20:03:17.255>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-10-23.20:03:17.255>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-10-23.20:03:17.257>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core', 'Unicode']
    creation = <Date 2017-07-06.07:53:21.848>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30863
    keywords = []
    message_count = 5.0
    messages = ['297813', '322252', '322265', '322268', '328340']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'ezio.melotti', 'serhiy.storchaka']
    pr_nums = ['2599']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue30863'
    versions = ['Python 3.8']

    @serhiy-storchaka
    Copy link
    Member Author

    Since Python 3.3 PyUnicode_AsUnicodeAndSize() is deprecated in favour of PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). But the latter two are implemented using PyUnicode_AsUnicodeAndSize(). This prevents adding the deprecation compiler warning for PyUnicode_AsUnicodeAndSize(). Other side effect -- PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() cache the wchar_t* representation of the PyUnicode object increasing its memory consumption.

    Proposed patch reimplements PyUnicode_AsWideChar(), PyUnicode_AsWideCharString() and PyUnicode_AsUnicodeAndSize() using two common helper functions. PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() no longer cache the wchar_t* representation.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-unicode performance Performance or resource usage labels Jul 6, 2017
    @serhiy-storchaka
    Copy link
    Member Author

    Victor already wrote similar patch in bpo-22323.

    @vstinner
    Copy link
    Member

    Would it be possible to remove the wchar_t* cache?

    @serhiy-storchaka
    Copy link
    Member Author

    Only after removing PyUnicode_AsUnicodeAndSize() and related PyArg_ParseTuple codes.

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset c46db92 by Serhiy Storchaka in branch 'master':
    bpo-30863: Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). (GH-2599)
    c46db92

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes and removed 3.7 (EOL) end of life labels Oct 23, 2018
    @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 topic-unicode
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants