On Jan 21, 2015, at 18:13, Alexander Belopolsky <alexander.belopolsky@gmail.com> wrote:

Sorry, I misread what you wrote.  I thought you suggested that an interned string can get "uninterned" somehow.  Yes, sys.intern(x) will change x's status, but as you suggested, it can change x.__class__ as well.  However, with a Symbol class in-place, I don't think there will be a need for such transitions.  Even now, I don't see sys.intern() in user code too often.

Probably because the difference between interned and uninterned strings isn't relevant too often. In Python, there is nothing extra you could do with an interned string or symbol that you can't do with a normal string. So the only conceivable benefit is as a performance optimization. And even that won't come up very often--if your hotspot is string comparisons between static or long-lived strings, most likely you're doing something wrong at a much bigger level (e.g., you've got a long chain of elif comparisons where you should have a dict). It's there on the occasions when it's really needed, but the fact that people rarely use it implies that there isn't a need to expand on it with an interned_string class, or anything else.

On Wed, Jan 21, 2015 at 9:08 PM, Alexander Belopolsky <alexander.belopolsky@gmail.com> wrote:

On Wed, Jan 21, 2015 at 5:18 PM, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
Alexander Belopolsky wrote:

Why can't we make interned strings a subclass of strings like bool is a subclass of int?

Because a string can change from being non-interned to
being interned at some point in its life.

I did not know that.  Can you show the code that would cause such a change?
 

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/