Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'encoding': 0.05; 'subject:Python': 0.06; 'amounts': 0.07; 'utf-8': 0.07; 'string': 0.09; 'bytes.': 0.09; 'encode': 0.09; 'optimizing': 0.09; 'subject: [': 0.09; '(something': 0.16; 'bits.': 0.16; 'codecs': 0.16; 'encodings': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'germane': 0.16; 'reedy': 0.16; 'three:': 0.16; 'tweak': 0.16; 'wrote:': 0.18; 'later': 0.20; 'fit': 0.20; 'options': 0.25; 'subject:/': 0.26; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'are.': 0.31; 'yes.': 0.31; 'fri,': 0.33; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'useful': 0.36; 'thanks': 0.36; 'detail': 0.37; 'two': 0.37; 'received:209': 0.37; 'performance': 0.37; 'being': 0.38; 'subject:]': 0.38; 'to:addr :python-list': 0.38; 'little': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'simple': 0.61; 'costs': 0.63; 'such': 0.63; 'mar': 0.68; '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:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=cM9XFez3jbfHxMztz9P3y9H3jMFbqNl8hZHJk9SVvWQ=; b=IqUKm6dg5mSyIgwoGtup2ZiYia3w8sv0XEcWRQm6MjPSlPFXjRc2LtUrILfJnAX1WW MV3xYHhu1OraQrE0xUEB+25UvQC+wYwznyahS8eN+VJq6pJ6HndBrPUHY7bM3VYVCmW8 v3jRX2FExyPGRyqu7OF6ULN8JrfWzU77spZ1W8frfkna8t7BEX4W0ef35HF2uKpJP2wT GdrbDXPExTj2RhCvi5ynQGwr/uPSJ0mqs/XGCNMZVKctIV7r8beoc/IrEQl0z8T6EF4w 5bqZpE9rQ/pAzkHrdHLZtjdmLqwWTGtqstT+OAjOb/TlFkMj9l4DTz4RnyCaaEzC42PX qKLA== MIME-Version: 1.0 X-Received: by 10.52.88.197 with SMTP id bi5mr23465184vdb.58.1364487415786; Thu, 28 Mar 2013 09:16:55 -0700 (PDT) In-Reply-To: References: <0b779c80-4f50-4716-8c30-47755c15f304@m12g2000yqp.googlegroups.com> <5153a12d$0$29998$c3e8da3$5496439d@news.astraweb.com> <987c4bd9-0e5e-4387-9c78-1075a77d3c47@c6g2000yqh.googlegroups.com> <51543f45$0$29998$c3e8da3$5496439d@news.astraweb.com> <944f195c-cbfe-47e1-a963-05fe3d98238d@5g2000yqz.googlegroups.com> Date: Fri, 29 Mar 2013 03:16:55 +1100 Subject: Re: flaming vs accuracy [was Re: Performance of int/long in Python 3] 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: 1364487418 news.xs4all.nl 6893 [2001:888:2000:d::a6]:49909 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42166 On Fri, Mar 29, 2013 at 3:01 AM, Terry Reedy wrote: > On 3/28/2013 10:38 AM, Chris Angelico wrote: > >> PEP393 strings have two optimizations, or kinda three: >> >> 1a) ASCII-only strings >> 1b) Latin1-only strings >> 2) BMP-only strings >> 3) Everything else >> >> Options 1a and 1b are almost identical - I'm not sure what the detail >> is, but there's something flagging those strings that fit inside seven >> bits. (Something to do with optimizing encodings later?) > > > Yes. 'Encoding' an ascii-only string to any ascii-compatible encoding > amounts to a simple copy of the internal bytes. I do not know if *all* the > codecs for such encodings are 393-aware, but I do know that the utf-8 and > latin-1 group are. This is one operation that 3.3+ does much faster than > 3.2- Thanks Terry. So that's not so much a representation difference as a flag that costs little or nothing to retain, and can improve performance in the encode later on. Sounds like a useful tweak to the basics of flexible string representation, without being particularly germane to jmf's complaints. ChrisA