Bitshifts and "And" vs Floor-division and Modular

jimbo1qaz jimmyli1528 at gmail.com
Thu Sep 6 21:05:41 EDT 2012


On Thursday, September 6, 2012 5:30:05 PM UTC-7, Mark Lawrence wrote:
> On 07/09/2012 01:01, jimbo1qaz wrote:
> 
> > Is it faster to use bitshifts or floor division? And which is better, & or %?
> 
> > All divisors and mods are power of 2, so are binary operations faster? And are they considered bad style?
> 
> >
> 
> 
> 
> Why don't you use the timeit module and find out for yourself?
> 
> 
> 
> -- 
> 
> Cheers.
> 
> 
> 
> Mark Lawrence.

How do I use it? timeit.timer is not defined.



More information about the Python-list mailing list