Serhiy Storchaka added the comment:

Interesting, short string literals usually are interned, but they are not 
interned in tuple literal.

>>> namespace = {}
>>> exec('a = ["abc123"]\ndef abc123(): pass', namespace)
>>> namespace['abc123'].__name__ is namespace['a'][0]
True
>>> exec('a = ("abc123",)\ndef abc123(): pass', namespace)
>>> namespace['abc123'].__name__ is namespace['a'][0]
False
>>> namespace['abc123'].__name__ == namespace['a'][0]
True

I think it would be better to change the compiler to always intern short string 
literals. And patching namedtuple will be not needed.

----------
nosy: +benjamin.peterson, brett.cannon, georg.brandl, ncoghlan, yselivanov

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25981>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to