Skip to content

Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() #75046

Closed

Description

@serhiy-storchaka
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']

    Activity

    1. serhiy-storchaka commented on Jul 6, 2017

      @serhiy-storchaka
      MemberAuthor

      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.

    2. serhiy-storchaka commented on Jul 23, 2018

      @serhiy-storchaka
      MemberAuthor

      Victor already wrote similar patch in bpo-22323.

    3. vstinner commented on Jul 23, 2018

      @vstinner
      Member

      Would it be possible to remove the wchar_t* cache?

    4. serhiy-storchaka commented on Jul 23, 2018

      @serhiy-storchaka
      MemberAuthor

      Only after removing PyUnicode_AsUnicodeAndSize() and related PyArg_ParseTuple codes.

    5. serhiy-storchaka commented on Oct 23, 2018

      @serhiy-storchaka
      MemberAuthor

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

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions