This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString()
Type: resource usage Stage: resolved
Components: Interpreter Core, Unicode Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2017-07-06 07:53 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 2599 merged serhiy.storchaka, 2017-07-06 07:56
Messages (5)
msg297813 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-07-06 07:53
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.
msg322252 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-23 20:10
Victor already wrote similar patch in issue22323.
msg322265 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-23 21:42
Would it be possible to remove the wchar_t* cache?
msg322268 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-07-23 22:00
Only after removing PyUnicode_AsUnicodeAndSize() and related PyArg_ParseTuple codes.
msg328340 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-23 19:58
New changeset c46db9232f1a6e0e3c33053549d03d4335db9dca by Serhiy Storchaka in branch 'master':
bpo-30863: Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). (GH-2599)
https://github.com/python/cpython/commit/c46db9232f1a6e0e3c33053549d03d4335db9dca
History
Date User Action Args
2022-04-11 14:58:48adminsetgithub: 75046
2018-10-23 20:03:17serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.8, - Python 3.7
2018-10-23 19:58:28serhiy.storchakasetmessages: + msg328340
2018-07-23 22:00:26serhiy.storchakasetmessages: + msg322268
2018-07-23 21:42:08vstinnersetmessages: + msg322265
2018-07-23 20:11:11serhiy.storchakasetmessages: - msg322251
2018-07-23 20:10:59serhiy.storchakasetmessages: + msg322252
2018-07-23 20:09:11serhiy.storchakasetmessages: + msg322251
2017-07-06 07:56:29serhiy.storchakasetpull_requests: + pull_request2667
2017-07-06 07:53:21serhiy.storchakacreate