Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58969
| References | (2 earlier) <527d85e8$0$29983$c3e8da3$5496439d@news.astraweb.com> <39112f0b-f834-4e4a-86f2-ca19078e6de4@googlegroups.com> <mailman.2283.1383985583.18130.python-list@python.org> <roy-9831F9.09375409112013@news.panix.com> <527e569f$0$29972$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| Date | 2013-11-10 09:14 +1100 |
| Subject | Re: chunking a long string? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2310.1384035279.18130.python-list@python.org> (permalink) |
On Sun, Nov 10, 2013 at 2:37 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > I think that Chris is wrong about Python "only" interning > strings if you explicitly ask for it. I recall that Python will (may?) > automatically intern strings which look like identifiers (e.g. "spam" but > not "Hello World" or "123abc"). I'm pretty sure it's simply that literals are interned, or at least shared across a module (and the interactive interpreter "counts" as a module). And it might still only be ones which look like identifiers, because: >>> foo = "lorem ipsum dolor sit amet" >>> bar = "lorem ipsum dolor sit amet" >>> foo is bar False My "only" was false because of the sharing/interning of (some) literals, which I'd forgotten about; however, there's still the distinction that I was trying to draw, that in Python _some strings_ are interned (a feature you can explicitly request), rather than _all strings_ being interned. And as is typical of python-list, it's this extremely minor point that became the new course of the thread - my main point was not whether all, some, or no strings get interned, but that string interning makes the storage space of duplicate strings immaterial :) ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
chunking a long string? Roy Smith <roy@panix.com> - 2013-11-08 12:48 -0500
Re: chunking a long string? wxjmfauth@gmail.com - 2013-11-08 12:43 -0800
Re: chunking a long string? Chris Angelico <rosuav@gmail.com> - 2013-11-09 07:53 +1100
Re: chunking a long string? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-08 20:57 +0000
Re: chunking a long string? Tim Chase <python.list@tim.thechases.com> - 2013-11-08 15:04 -0600
Re: chunking a long string? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-08 21:06 +0000
Re: chunking a long string? Chris Angelico <rosuav@gmail.com> - 2013-11-09 08:04 +1100
Re: chunking a long string? Chris Angelico <rosuav@gmail.com> - 2013-11-09 08:17 +1100
Re: chunking a long string? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-09 00:46 +0000
Re: chunking a long string? wxjmfauth@gmail.com - 2013-11-09 00:14 -0800
Re: chunking a long string? Chris Angelico <rosuav@gmail.com> - 2013-11-09 19:26 +1100
Re: chunking a long string? Roy Smith <roy@panix.com> - 2013-11-09 09:37 -0500
Re: chunking a long string? Chris Angelico <rosuav@gmail.com> - 2013-11-10 02:02 +1100
Re: chunking a long string? Roy Smith <roy@panix.com> - 2013-11-09 10:21 -0500
Re: chunking a long string? Chris Angelico <rosuav@gmail.com> - 2013-11-10 02:30 +1100
Re: chunking a long string? Roy Smith <roy@panix.com> - 2013-11-09 10:35 -0500
Re: chunking a long string? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-09 15:37 +0000
Re: chunking a long string? Chris Angelico <rosuav@gmail.com> - 2013-11-10 09:14 +1100
Re: chunking a long string? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-10 06:39 +0000
Re: chunking a long string? Chris Angelico <rosuav@gmail.com> - 2013-11-10 19:46 +1100
Re: chunking a long string? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-09 10:13 +0000
Re: chunking a long string? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-09 00:54 +0000
csiph-web