[Python-ideas] Keyword/Symbol literals

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jan 21 23:24:23 CET 2015

Chris Angelico wrote:
> If, in the fourth example, the interpreter knew that both those string
> objects were interned, it could know that they can't possibly be the
> same string. So is that distinction worth coding into the class
> hierarchy?

I believe there is a flag in the string object indicating
that it is interned, so the interpreter *does* know this.
It's just not visible to Python code.

Switching the class would achieve the same thing and make
it visible, but is there any need for it to be? And even
if there is, an is_interned() function would achieve the
same purpose without having an immutable type magically
changing its class.


More information about the Python-ideas mailing list