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.

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

Created on 2016-07-05 13:01 by methane, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
intern-setdefault.patch methane, 2016-07-05 13:01 review
intern-setdefault2.patch methane, 2016-07-06 01:40 review
Messages (6)
msg269819 - (view) Author: Inada Naoki (methane) * (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 (methane) * (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
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
msg271201 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-07-25 01:41
Date User Action Args
2022-04-11 14:58:33adminsetgithub: 71641
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:05methanesetfiles: + 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:36methanecreate