def highest_bit(n, maxbits = 256): bit = 0 while maxbits > 1: maxbits >>= 1 a = n >> maxbits if a: bit += maxbits n = a return bit
is sligtly better -- http://mail.python.org/mailman/listinfo/python-list
def highest_bit(n, maxbits = 256): bit = 0 while maxbits > 1: maxbits >>= 1 a = n >> maxbits if a: bit += maxbits n = a return bit
is sligtly better -- http://mail.python.org/mailman/listinfo/python-list