On Oct 5, 2:12 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]>
wrote:
> Duncan Booth wrote:
> > [EMAIL PROTECTED] wrote:
>
> > OFFSET = dict(("%x"%i, int(c)) for i,c in enumerate("5433222211111111"))
> > def get_highest_bit_num(r):
> > s = "%x"%r
> > return len(s) * 4 - OFFSET[s[0]]
>
> OFFSET= tuple( int(x) for x in "5433222211111111" )
> def get_highest_bit_num(r):
> s = "%x"%r
> return len(s) * 4 - OFFSET[int(s[0],16)]
That's really counterintuitive. (That's the word, yes.) They're both
function calls and both global variables. Maybe you could use 'len(s)
* 4' to mask out the rest and lookup that index, rather than
converting -back- to integer. Or, better yet, take 'ord' of s[0].
(Ha ha, -you- time it.)
--
http://mail.python.org/mailman/listinfo/python-list