classification
Title: PyUnicode_InternInPlace can use PyDict_SetDefault
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, inada.naoki, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2016-07-05 13:01 by inada.naoki, last changed 2016-07-25 01:41 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
intern-setdefault.patch inada.naoki, 2016-07-05 13:01 review
intern-setdefault2.patch inada.naoki, 2016-07-06 01:40 review
Messages (6)
msg269819 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2016-07-05 13:01
PyDict_SetDefault() was added Python 3.4

Currently, PyUnicode_InternInPlace() uses PyDict_GetItem, and PyDict_SetItem if no item found.
It can be replaced PyDict_SetDefault() easily.
msg269823 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-07-05 14:04
I think you also need to update the comment below:

    /* It might be that the GetItem call fails even
       though the key is present in the dictionary,
       namely when this happens during a stack overflow. */
msg269863 - (view) Author: Inada Naoki (inada.naoki) * (Python committer) Date: 2016-07-06 01:40
Thank you for pointing it out.
That comment seems useless when removing PyDict_GetItem().  So I removed it.
msg271096 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-07-23 18:10
LGTM.
msg271200 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-07-25 01:40
New changeset f3187a157204 by Berker Peksag in branch 'default':
Issue #27454: Use PyDict_SetDefault in PyUnicode_InternInPlace
https://hg.python.org/cpython/rev/f3187a157204
msg271201 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-07-25 01:41
Thanks!
History
Date User Action Args
2016-07-25 01:41:04berker.peksagsetstatus: open -> closed
resolution: fixed
messages: + msg271201

stage: commit review -> resolved
2016-07-25 01:40:35python-devsetnosy: + python-dev
messages: + msg271200
2016-07-23 18:10:44serhiy.storchakasetmessages: + msg271096
stage: patch review -> commit review
2016-07-06 01:40:05inada.naokisetfiles: + intern-setdefault2.patch

messages: + msg269863
2016-07-05 14:04:42berker.peksagsetnosy: + berker.peksag, vstinner, serhiy.storchaka

messages: + msg269823
stage: patch review
2016-07-05 13:01:36inada.naokicreate