Challenge: optimizing isqrt

Serhiy Storchaka storchaka at
Tue Nov 25 20:31:43 CET 2014

п'ятниця, 21-лис-2014 08:15:57 ви написали:
> This looks very good indeed. As a matter of interest, is there any
> particular reason you have used 2*b instead of b+b? Might b+b be faster
> than b*2?

Yes, it is slightly faster, but the effect is indiscernible in total 
time. But
there is not harm to use b+b.

> Also, in various lines, you use //2. Would >>1 be quicker? On reflection,
> perhaps you have had to use //2 because >>1 cannot be used in those
> situations.

I thought this effect would be insignificant too. But actually it is 
(about 10% for some input). Thanks, this optimization is worth to be 

More information about the Python-list mailing list