And this, ladies and gentlemen, is how you <i>not</i> make speed comparisons.<p>#7 surprised me: why would 'if a:' be slower than 'if not a:'? So I ran the code myself, and ran it a few times. And lo and behold, the third digit varies greatly between runs. And the timing between the first and second variant only differ in the third digit.<p>I ran the first and second variant ten times, and got these values:<p>first: 0.138 +- 0.05<p>second: 0.137 +- 0.04<p>So there is no significant difference in my timings, though individual runs differed as much as 0.132 vs. 0.150.<p>Though kudos for providing the full code and the raw output. It made quite easy to reproduce!<p>These are the timings I measured, in octave/matlab syntax:<p><pre><code> t1 = [0.132781028748, 0.140866041183, 0.13587808609, 0.138177871704, 0.137129068375, 0.150414943695, 0.138676166534, 0.137069940567, 0.13484787941, 0.136043071747];
mean(t1)
std(t1)
t2 = [ 0.134783983231, 0.143576860428, 0.138277769089, 0.142880916595, 0.140572071075, 0.136868000031, 0.131128787994, 0.134744167328, 0.132730007172, 0.137500047684];
mean(t2)
std(t2)</code></pre>