New submission from Serhiy Storchaka:

Usually string literals are interned. But not if they are a part of constant 
tuple.

>>> def abc(): pass
... 
>>> x = 'abc'
>>> x is abc.__name__
True
>>> x = ('abc',)
>>> x[0] is abc.__name__
False

This makes effect on namedtuples (issue25981). May make effect on __slots__ or 
other uses of constant tuples since searching a value in a tuple when values 
are not identical is a little slower that when they are identical.

----------
components: Interpreter Core
messages: 258542
nosy: benjamin.peterson, brett.cannon, georg.brandl, haypo, ncoghlan, 
rhettinger, serhiy.storchaka, yselivanov
priority: normal
severity: normal
status: open
title: String literals are not interned if in a tuple

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

Reply via email to