Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.049 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'variables': 0.07; 'lawrence': 0.09; 'cc:addr:python-list': 0.11; 'cares': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'umpteen': 0.16; 'whatsoever': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'thu,': 0.19; 'version.': 0.19; 'code,': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'fastest': 0.30; 'is?': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'wrong': 0.37; 'two': 0.37; 'performance': 0.37; 'pm,': 0.38; 'extremely': 0.39; 'either': 0.39; 'how': 0.40; 'read': 0.60; 'impact': 0.61; 'first': 0.61; 'times': 0.62; 'design.': 0.68; 'other.': 0.75; '2014,': 0.84; 'sweeping': 0.84; 'to:none': 0.92 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:cc :content-type; bh=W7QsGcFOFp55/nZM25XxsqvxOvNvpkw/jxRZdvovWqQ=; b=vt+aI99KR/NtCCSndGoP/Vc/Mo52tsjos1AKasr1Q0rEDb0a4tR7BF06YGVlEN1c3A CJqUfdICaQBoF8BXEkGvqLluxoCbEJJdAqNWs0Dri2Nd+WRw2qN1qF+OqLU3eFoBFA2h Ps9Iidt61u0Opbe0/cUKltqpPaJvCFSgYgvKDiLjwPZg0yR5COMBEX0bXXAdArg1mgJN wePTnpJD9oSK/zeWZSpxdsZXMzKEcu9z//s0r8SN25NtKt3slu/oxmsd6ay0U2Evltff OLW0UeBD5ZTLGGsZZaYHetGnQDQ1M4ZZ5QYq4EvXedwHnRh6k/xtHv9yfesTM5YJoAgm 2qBQ== MIME-Version: 1.0 X-Received: by 10.43.94.7 with SMTP id bw7mr3660136icc.26.1412827043264; Wed, 08 Oct 2014 20:57:23 -0700 (PDT) In-Reply-To: <1412826846.1947388.176878769.2F8374DF@webmail.messagingengine.com> References: <1412826846.1947388.176878769.2F8374DF@webmail.messagingengine.com> Date: Thu, 9 Oct 2014 14:57:23 +1100 Subject: Re: Toggle From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412827051 news.xs4all.nl 2903 [2001:888:2000:d::a6]:40699 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78872 On Thu, Oct 9, 2014 at 2:54 PM, wrote: > On Wed, Oct 8, 2014, at 23:02, Mark Lawrence wrote: >> When I first read this I was extremely jealous of the originator but >> having used it umpteen times I'm still extremely jealous of the >> originator!!! Why doesn't my mind work like his? :) > > You could also keep the ints in two variables and do a ^= b : b ^= a : a > ^= b. Or use a, b = b, a. What I don't see in that answer is any > benchmarking support for his sweeping assertions of what is the fastest > version. Possibly because it doesn't matter. Who cares how fast it is? All you need to do is go from either of two states to the other. If the performance of that has any impact whatsoever on your code, there's something wrong with your design. ChrisA