<div class="gmail_quote">On Wed, Jan 5, 2011 at 9:15 AM, Peter Otten <span dir="ltr"><__<a href="mailto:peter__@web.de">peter__@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Jacek Krysztofik wrote:<br>
<br>
> Sorry for OT, but this is actually a question of mine<br>
>>                 if numbers % 2 == 0:<br>
> wouldn't the following be faster?<br>
>>                 if numbers & 1 == 0:<br>
<br>
</div>You can answer that and similar questions yourself with the timeit module:<br>
<br>
$ python -m timeit -s'm, n = 1234, 1235' 'm % 2 == 0; n % 2 == 0'<br>
1000000 loops, best of 3: 0.377 usec per loop<br>
<br>
$ python -m timeit -s'm, n = 1234, 1235' 'm & 1 == 0; n & 1 == 0'<br>
1000000 loops, best of 3: 0.298 usec per loop<br>
<br>
So yes, a binary and seems to be faster.<br></blockquote><div><br>I would be curious to hear of a Python application where such a small speed difference mattered even a little bit.  Looks to me like a pretty meaningless difference.<br>
<br>Carey<br></div></div>