Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58950

Re: chunking a long string?

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 <rosuav@gmail.com>
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 <roy-4EDEFD.10212609112013@news.panix.com>
References <mailman.2232.1383932895.18130.python-list@python.org> <c1bb3377-4425-4707-9ae7-aa7251cebc75@googlegroups.com> <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> <mailman.2298.1384009376.18130.python-list@python.org> <roy-4EDEFD.10212609112013@news.panix.com>
Date Sun, 10 Nov 2013 02:30:16 +1100
Subject Re: chunking a long string?
From Chris Angelico <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2301.1384011026.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Sun, Nov 10, 2013 at 2:21 AM, Roy Smith <roy@panix.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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