Title: tags for anonymous code objects should be interned
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Daniel Moisset, rhettinger, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-04-12 20:32 by Daniel Moisset, last changed 2018-04-15 22:13 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6472 merged ZackerySpytz, 2018-04-14 17:17
Messages (4)
msg315232 - (view) Author: Daniel Moisset (Daniel Moisset) * Date: 2018-04-12 20:32
In compile.c, some strings are created to be used as name of anonymous code objects: "<module>", "<lambda>", "<genexpr>", "<listcomp>", "<setcomp>" and "<dictcomp>".

Only the first two of those are interned (created with PyUnicode_InternFromString ), the rest are created with "PyUnicode_FromString". Even if they use a static variable to avoid creating multiple instances, not interning results in multiple copies when code objects are marshaled into pyc files and reloaded (one copy per module).

Always using PyUnicode_InternFromString should be more consistent, and slightly more efficient
msg315263 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2018-04-13 20:13
msg315345 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-15 22:12
New changeset f303639e3ac96cfe6c1438f1c594226941f46216 by Serhiy Storchaka (Zackery Spytz) in branch 'master':
bpo-33270: Intern names for all anonymous code objects (#6472)
msg315346 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-15 22:13
Thank you for your contribution Zackery.
Date User Action Args
2018-04-15 22:13:46serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg315346

stage: patch review -> resolved
2018-04-15 22:12:32serhiy.storchakasetmessages: + msg315345
2018-04-15 20:29:45pitrousetnosy: + serhiy.storchaka
2018-04-14 17:17:53ZackerySpytzsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request6171
2018-04-13 20:13:59rhettingersetnosy: + rhettinger
messages: + msg315263
2018-04-13 18:41:48brett.cannonsetstage: needs patch
type: enhancement
versions: + Python 3.8
2018-04-12 20:32:14Daniel Moissetcreate