Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string.': 0.04; 'python': 0.08; 'subject:string': 0.09; 'wrote:': 0.15; 'appends': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:formatting': 0.16; 'subject:vs.': 0.16; 'pm,': 0.16; 'url:blog': 0.16; 'received:209.85.210.174': 0.19; 'received:mail- iy0-f174.google.com': 0.19; "doesn't": 0.22; 'header:In-Reply- To:1': 0.22; 'string': 0.26; 'fine': 0.26; 'guess': 0.28; 'sat,': 0.28; 'all,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'unicode': 0.29; 'url:ca': 0.29; 'remains': 0.30; 'strings,': 0.30; 'to:addr :python-list': 0.34; 'optimization': 0.36; 'page': 0.36; 'url:python': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'steven': 0.38; 'to:addr:python.org': 0.39; 'plain': 0.40; 'received:209': 0.40; 'page:': 0.40; 'subject:. ': 0.66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=DhYbDK8OaIp+i8VGpqapC1vWvRnnUsBlBKBZphyMgpo=; b=cN7BDY9n1L/U2zjkiKNEU/DQZkNH5gxpaPMqZx4Qkm3OYso5YwAIzQdUyfFADalNPE HD6dIvTKXu4NthC4M7jtEiANa6y/8JAGN9o2A9KDQyT93RHHhUtRKWViyXoFGvZhLYZo QSPNo2ct7eg/8UjaHolPiHEqh1G9GpcO/SDUA= MIME-Version: 1.0 In-Reply-To: <4e17e790$0$29977$c3e8da3$5496439d@news.astraweb.com> References: <4e17e790$0$29977$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 9 Jul 2011 16:16:55 +1000 Subject: Re: String concatenation vs. string formatting 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.12 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1310192219 news.xs4all.nl 21766 [2001:888:2000:d::a6]:45933 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9110 On Sat, Jul 9, 2011 at 3:30 PM, Steven D'Aprano wrote: > It also doesn't generalise: only appends are optimized, not prepends. > > If you're interested in learning about the optimization: > > http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt >From that page: "Also, this is only for plain (byte) strings, not for Unicode strings; as of Python 2.4.2, Unicode string concatenation remains un-optimized." Has the same optimization been implemented for Unicode? The page doesn't mention Python 3 at all, and I would guess that the realloc optimization would work fine for both types of string. ChrisA