[New-bugs-announce] [issue33270] tags for anonymous code objects should be interned

Daniel Moisset report at bugs.python.org
Thu Apr 12 16:32:14 EDT 2018

New submission from Daniel Moisset <dmoisset at machinalis.com>:

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

components: Interpreter Core
messages: 315232
nosy: Daniel Moisset
priority: normal
severity: normal
status: open
title: tags for anonymous code objects should be interned

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list