This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2016年01月18日 20:09 by serhiy.storchaka, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg258542 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年01月18日 20:09 | |
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.
|
|||
| msg258594 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2016年01月19日 13:58 | |
FYI fatoptimizer has a more efficient algorithm to merge constants: http://fatoptimizer.readthedocs.org/en/latest/optimizations.html#comparison-with-the-peephole-optimizer It looks like it interns strings which are part of tuples. To be honest, I don't understand how it works, but it works :-) |
|||
| msg277361 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2016年09月25日 10:44 | |
The patch is provided in issue27942. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:26 | admin | set | github: 70336 |
| 2016年09月25日 10:44:49 | serhiy.storchaka | set | status: open -> closed superseder: Default value identity regression messages: + msg277361 resolution: duplicate stage: resolved |
| 2016年04月26日 08:51:12 | serhiy.storchaka | link | issue25981 superseder |
| 2016年01月19日 13:58:38 | vstinner | set | messages: + msg258594 |
| 2016年01月19日 13:41:24 | vstinner | set | versions: + Python 3.6 |
| 2016年01月19日 13:41:17 | vstinner | set | type: performance |
| 2016年01月18日 20:09:48 | serhiy.storchaka | create | |