Number of bits/sizeof int

casevh casevh at
Mon Feb 2 23:47:47 CET 2009

On Jan 30, 11:03 pm, Jon Clements <jon... at> wrote:
> Hi Group,
> This has a certain amount of irony (as this is what I'm pretty much
> after):-
> From
> "The int() type gained a bit_length method that returns the number of
> bits necessary to represent its argument in binary:"
> Any tips on how to get this in 2.5.2 as that's the production version
> I'm stuck with.
> Cheers,
> Jon.

If performance does become an issue, the newly released gmpy 1.04
includes bit_length().


More information about the Python-list mailing list