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.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; ':-)': 0.06; 'python': 0.08; 'operation,': 0.09; 'subject:" ': 0.10; 'algorithm': 0.13; 'algorithmic': 0.16; 'andreas': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:=': 0.16; "wouldn't": 0.17; 'header:In-Reply-To:1': 0.22; '(even': 0.29; 'message- id:@mail.gmail.com': 0.29; 'do.': 0.30; 'agreed.': 0.30; 'equivalent': 0.31; 'to:addr:python-list': 0.33; 'improvements': 0.34; 'shorter': 0.34; 'using': 0.37; 'but': 0.37; 'think': 0.38; 'some': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'subject: (': 0.39; 'where': 0.40; 'easily': 0.61; 'your': 0.61; 'alternative': 0.64; 'ever': 0.65; '"for': 0.67; 'subject:+': 0.73 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:content-transfer-encoding; bh=ObAg/agXmSTphjTjOQ1Txe5F0aggYrrquH1qednr1cc=; b=ASTYH2rMgCoG00ne1dYYvyefUr7m67+Nzf6dSDNXxCybUjdcc+KXmwGHzwPEEeU39F mBRgExiqfRG0TGdjedfv07drGTW0KE7/ooU2BQVVxce3ZwmR4c11hkcz20/ET+yPi9zy GrssK3SuwHylJdJ6lp6n2Ya2LEXRMY/nJxsig= MIME-Version: 1.0 In-Reply-To: <1313969134.3135.21.camel@thegeorge> References: <4e513ceb$0$23863$e4fe514c@news2.news.xs4all.nl> <1313947658.3424.3.camel@thegeorge> <747a8223-0a9b-4691-8886-0a04433e54dc@glegroupsg2000goo.googlegroups.com> <1313969134.3135.21.camel@thegeorge> Date: Mon, 22 Aug 2011 00:41:43 +0100 Subject: Re: relative speed of incremention syntaxes (or "i=i+1" VS "i+=1") From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313970106 news.xs4all.nl 23929 [2001:888:2000:d::a6]:35792 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11972 2011/8/22 Andreas L=F6scher : > But every improvement on your algorithm will easily result in a > significant shorter execution time than replaceing a+=3D1 with a=3Da+1 wi= ll > ever do. :-) > Agreed. If Python needed a faster alternative to "a=3Da+1", then I would recommend an "a.inc()" call or something; some way to avoid looking up the value of 1. (An equivalent to C's ++a operation, if you like.) But I think you'd be hard-pressed to find any situation where improving the speed of incrementing will be significant, that wouldn't be better served by algorithmic improvements (even just using "for a in range()") or dropping to C. ChrisA