[issue3439] math.frexp and obtaining the bit size of a large integer

Mark Dickinson report at bugs.python.org
Sun Jul 27 08:29:54 CEST 2008


Mark Dickinson <dickinsm at gmail.com> added the comment:

I'd also be interested in having _PyLong_NumBits exposed to Python in some 
way or another.  It's something I've needed many times before, and it's 
used in the decimal module, for example.

My favorite workaround uses hex instead of bin:

4*len('%x'%x) - correction_dictionary[first_hexdigit_of_x]

but this is still O(log x) rather than O(1).

----------
nosy: +marketdickinson

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3439>
_______________________________________


More information about the Python-bugs-list mailing list