chunking a long string?
roy at panix.com
Sat Nov 9 16:21:26 CET 2013
In article <mailman.2298.1384009376.18130.python-list at python.org>,
Chris Angelico <rosuav at gmail.com> wrote:
> On Sun, Nov 10, 2013 at 1:37 AM, Roy Smith <roy at panix.com> wrote:
> > In article <mailman.2283.1383985583.18130.python-list at python.org>,
> > Chris Angelico <rosuav at gmail.com> 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()
> [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 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
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
and that Pike implements #1, while Python implements #3 and #4.
More information about the Python-list