Toggle

Chris Angelico rosuav at gmail.com
Thu Oct 9 05:57:23 CEST 2014


On Thu, Oct 9, 2014 at 2:54 PM,  <random832 at fastmail.us> 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



More information about the Python-list mailing list