Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'explicitly': 0.05; 'interpreter': 0.05; 'duplicate': 0.07; 'string': 0.09; 'subject:string': 0.09; 'python': 0.11; 'thread': 0.14; '"hello': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'identifiers': 0.16; 'identifiers,': 0.16; 'literals': 0.16; 'literals,': 0.16; 'module).': 0.16; 'python-list,': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'module': 0.19; 'trying': 0.19; '>>>': 0.22; 'typical': 0.24; 'least': 0.26; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'feature': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; "d'aprano": 0.31; 'minor': 0.31; 'steven': 0.31; '(e.g.': 0.33; "i'd": 0.34; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'subject:?': 0.36; 'wrong': 0.37; 'being': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'extremely': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'new': 0.61; 'course': 0.61; 'simply': 0.61; 'became': 0.64; '"spam"': 0.84; 'intern': 0.84; 'subject:long': 0.84; 'forgotten': 0.91; 'request),': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ksiqJHfD/wvLZGLnIF5/AVwlsT6iZtN2kKI6sAjrQow=; b=NARsMclmikzSszglhT8FKjN7savhyBZ4K5vUGP2Rw0w4TYfThNy/qXKFa4DvKssW0N gkgu1lbhuKiY9eQ61W3MCKrgh3KZaezzB71elYoxfZ1tw0aVGVpr3K8B/pqHRAUmP85A uWFc8L5OAOOCkTM/jzVj7TRY1aE7Oppo2/C4YVbcUMfj/vXQEnqOlKmXhnzNNDk5vISM LoPmTwABZ5aiwqhiEwXMybJnoszMqla+yoe92nA63f389BLkXc33dm2Y2EDcTBuDq4Vk jFfE6A+VWtfxOCf6I8s+/mJ6txZUAmQivslsj7MS9fnX++fDYFgOojXBuBt9aPUxBdRZ N0IA== MIME-Version: 1.0 X-Received: by 10.68.234.165 with SMTP id uf5mr22319943pbc.41.1384035268932; Sat, 09 Nov 2013 14:14:28 -0800 (PST) In-Reply-To: <527e569f$0$29972$c3e8da3$5496439d@news.astraweb.com> References: <527d85e8$0$29983$c3e8da3$5496439d@news.astraweb.com> <39112f0b-f834-4e4a-86f2-ca19078e6de4@googlegroups.com> <527e569f$0$29972$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 10 Nov 2013 09:14:28 +1100 Subject: Re: chunking a long string? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384035279 news.xs4all.nl 15994 [2001:888:2000:d::a6]:54026 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58969 On Sun, Nov 10, 2013 at 2:37 AM, Steven D'Aprano 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