chunking a long string?

Roy Smith roy at
Sat Nov 9 16:21:26 CET 2013

In article <mailman.2298.1384009376.18130.python-list at>,
 Chris Angelico <rosuav at> wrote:

> On Sun, Nov 10, 2013 at 1:37 AM, Roy Smith <roy at> wrote:
> > In article <mailman.2283.1383985583.18130.python-list at>,
> >  Chris Angelico <rosuav at> wrote:
> >
> >> Some languages [intern] automatically for all strings, others
> >> (like Python) only when you ask for it.
> >
> > What does "only when you ask for it" mean?
> You can explicitly intern a Python string with the sys.intern()
> function
> [long, and good, explanation of interning]

But, you missed the point of my question.  You said that Python does 
this "only when you ask for it".  That implies it never interns strings 
if you don't ask for it, which is clearly not true:

$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) 
>>> x = "foo"
>>> y = "foo"
>>> x is y

I think what you're trying to say is that there are several possible 
interning policies:

1) Strings are never interned

2) Strings are always interned

3) Strings are optionally interned, at the discretion of the 

4) The user may force a specific string to be interned by explicitly 
requesting it.

and that Pike implements #1, while Python implements #3 and #4.

More information about the Python-list mailing list