[New-bugs-announce] [issue26148] String literals are not interned if in a tuple

Serhiy Storchaka report at bugs.python.org
Mon Jan 18 15:09:48 EST 2016


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 <report at bugs.python.org>
<http://bugs.python.org/issue26148>
_______________________________________


More information about the New-bugs-announce mailing list