Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'explicitly': 0.05; 'string': 0.09; 'falls': 0.09; 'implements': 0.09; 'subject:string': 0.09; 'python': 0.11; 'missed': 0.12; 'question.': 0.14; 'ah!': 0.16; 'expect,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'implies': 0.16; 'it".': 0.16; 'literals': 0.16; 'mutable': 0.16; 'optionally': 0.16; 'presume': 0.16; 'roy': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'example': 0.22; 'file.': 0.24; 'source': 0.25; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'external': 0.29; 'am,': 0.29; 'forgot': 0.30; 'message- id:@mail.gmail.com': 0.30; 'gives': 0.31; 'that.': 0.31; '>>>>': 0.31; 'requesting': 0.31; 'restricted': 0.31; 'tuples': 0.31; 'lists': 0.32; 'languages': 0.32; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'possible': 0.36; 'subject:?': 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; "you're": 0.61; 'smith': 0.68; 'jul': 0.74; '2.7.1': 0.84; 'pike': 0.84; 'subject:long': 0.84; '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=23TGfbpdQa/fwVYohXPiJUjmObxTWQQJkQFpw6WItOY=; b=Q4Zt/8LNo8MZGqJ8N+1u/ae3/E8Ll53lhX73YFn2SaYe8cRlUCwRmoiEH2E2HhyGxU 0rvuI6VbwjglTp2AMyFIKR3n9TmBcf9wyj/FJYSDaRmkdA9WEQN66KL/QfHNeOzPNTda leQi7iru9+YhaeBgyA4PxhGZ1zji0I3fbZELKHZfprOt5jCJptuPbVhryxNX0qtkKXwH drWNLmAsbFTWLC5wQOsQraKDDY/U7YE3qCpOPZOnIpb7q9FzXq5moii5INjECCww2Szz Z6IVppwMpVo9L9fGGQ5gSkxsBI0+/hAehiQ2Hb20j01mWwZMS2bmr3XcNbMdI7P0vdg4 Ft/A== MIME-Version: 1.0 X-Received: by 10.66.248.202 with SMTP id yo10mr515679pac.177.1384011016228; Sat, 09 Nov 2013 07:30:16 -0800 (PST) In-Reply-To: References: <527d85e8$0$29983$c3e8da3$5496439d@news.astraweb.com> <39112f0b-f834-4e4a-86f2-ca19078e6de4@googlegroups.com> Date: Sun, 10 Nov 2013 02:30:16 +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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384011026 news.xs4all.nl 15908 [2001:888:2000:d::a6]:36118 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58950 On Sun, Nov 10, 2013 at 2:21 AM, Roy Smith wrote: > 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 > True Ah! Yes, that's true; literals are interned - I forgot that. But anything from an external source won't be, hence my example with reading in the contents of a file. > 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 > implementation > > 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. Pike implements #2, I presume that was a typo. And yes, the interning of literals falls under #3, while sys.intern() gives #4. Use of #1 would be restricted to languages with mutable strings, I would expect, for the same reason that Python tuples might be shared but lists won't be. ChrisA