Bit length of int or long?

Tim Peters tim_one at email.msn.com
Wed May 17 22:23:25 EDT 2000


[Greg Ewing]
> Here's one that should be O(log n) where n is the
> number of bits:

It's actually O(n * log n):  more efficient than Guido's <wink>, but can't
touch the old ones Michael posted links to.  The thing that trips most
people up when analyzing this is that a single shift by a small amount takes
O(n) time all by itself (Python has to copy all the bits that aren't shifted
off).

now-if-the-hw-had-unboundedly-wide-registers-...-ly y'rs  - tim






More information about the Python-list mailing list