In python 3.5, is it possible to predict when we will get an interned string or when we will get a copy? After reading a few Stack Overflow answers on this issue I've found this one the most helpful but still not comprehensive. Than I looked at Python docs, but the interning is not guaranteed by default
Normally, the names used in Python programs are automatically interned, and the dictionaries used to hold module, class or instance attributes have interned keys.
So, my question is about inner intern()
conditions, i.e. decision-making (whether to intern string literal or not): why the same piece of code works on one system and not on another one and what rules did author of the answer on mentioned topic mean when saying
the rules for when this happens are quite convoluted
==
and forget about it. It's implementation detail anyway. – Rhizoid==
? Is your question "when will a string will be interned in cpython?" Note that this is no longer a python question, because python the language may not even have string interning. – Rhizoidintern
is interned. Everything else is a morass of implementation details, inconsistent because there's little point to being consistent. – Lillylillywhite