New submission from Daniel Moisset <>:

In compile.c, some strings are created to be used as name of anonymous code 
objects: "<module>", "<lambda>", "<genexpr>", "<listcomp>", "<setcomp>" and 

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 <>
Python-bugs-list mailing list

Reply via email to