Claudio Grondi wrote:
>> You can get somewhat faster in Python than your code if you avoid
>> producing new long objects all the time, and do the task in chunks of 30
>> bits.
> 
> It would be nice if you could explain why you consider chunks of 30 bits
> to be superior e.g. to chunks of 32 bits?

With chunks of 32 bits, you might get negative numbers. Then,
right-shifting bit-by-bit will never get you to zero.

It also happens that the long ints are represented as arrays of
15-bit values, so that the shift by 30 *could* be implemented
without shifts in the individual words; however, this optimization
is not done.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to