Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.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.039 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.02; 'method.': 0.07; 'string': 0.09; 'formatting': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; "%s'": 0.16; "'%s": 0.16; '(1,': 0.16; '10000000': 0.16; '23,': 0.16; 'eckhardt': 0.16; 'gpg': 0.16; 'subject:format': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'steven': 0.31; 'url:python': 0.33; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'rather': 0.38; 'url:mail': 0.40; 'from:charset:utf-8': 0.61; 'between': 0.67; 'obvious': 0.74; 'greetings!': 0.84; 'off,': 0.84; 'subject:skip:o 10': 0.84; 'why?': 0.91; 'url:tk': 0.95; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=IQ/jFew4+QAw0jmLLOdCGCH/1LWcn9RYVspAkPV1/yo=; b=u2d0xI0SPG/VVVCQRhK820W/KdcAVdA6RppeY2pJdWXzaYhJXgoIuMdwzBnBBcR/0/ LxY41hNId8u9V5J8cyvVdcI2sfacqgO4H8iDmudEucWVExnmMkZh06ye+QwLYCBVCOEU kkkLqW2gieHGztxF/wgGUy0txNUfdotqbJg5NQH2dABxOo35ZxqWtD6Ph/5RsYrvlGln NS8JoFmdjTk9ICjhozkP3cGPDBy3AQd8RX7pTgPZ5gLIOLNKEWX34e8T6Beqjyunsff3 x35uEpjKuda2eEYN1wPzOUntYxvj1gLw89Efa2Zio2XybEk4yjNnqpcy/NWZcm6G7azo rl5w== X-Received: by 10.50.57.166 with SMTP id j6mr17705383igq.21.1366705620123; Tue, 23 Apr 2013 01:27:00 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <51760754$0$29872$c3e8da3$5496439d@news.astraweb.com> From: =?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?= Date: Tue, 23 Apr 2013 10:26:38 +0200 Subject: Re: percent faster than format()? (was: Re: optomizations) To: Ulrich Eckhardt Content-Type: text/plain; charset=UTF-8 Cc: python-list@python.org 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366705622 news.xs4all.nl 2198 [2001:888:2000:d::a6]:43819 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44167 On Tue, Apr 23, 2013 at 9:46 AM, Ulrich Eckhardt wrote: > Am 23.04.2013 06:00, schrieb Steven D'Aprano: >> >> If it comes down to micro-optimizations to shave a few microseconds off, >> consider using string % formatting rather than the format method. > > > Why? I don't see any obvious difference between the two... > > > Greetings! > > Uli > > -- > http://mail.python.org/mailman/listinfo/python-list $ python -m timeit "a = '{0} {1} {2}'.format(1, 2, 42)" 1000000 loops, best of 3: 0.824 usec per loop $ python -m timeit "a = '%s %s %s' % (1, 2, 42)" 10000000 loops, best of 3: 0.0286 usec per loop -- Kwpolska | GPG KEY: 5EAAEA16 stop html mail | always bottom-post http://asciiribbon.org | http://caliburn.nl/topposting.html