Bit length of int or long?

Laurent POINTAL pointal at lure.u-psud.fr
Thu May 18 12:30:52 EDT 2000


On Thu, 18 May 2000 09:16:30 -0700, Guido van Rossum
<guido at python.org> wrote:

>: 
>: In my defense: Francois didn't mention long ints in his first post. You'r=
>: e
>: right of course that a method of ints and longs is the right solution. An=
>: other
>: method should count '1' bits (useful when using long ints as sets of ints=
>: ).

As I remember, ADA has a "'Size" operation for number sizes (there is
also other operations for floating point numbers characteristics).

More generally, there may be a method in the sys module (as there is
already one which return the reference counter of an object), like
sys.getsize(x) which could return the full byte size of the object x,
and sys.getdatasize(x) which could return the byte size of the object
x without considering the header. [but I dont know if numbers have
extra-datas and if such methods could be applicable].

Note the sys.maxint which can be used to find how bytes are used.

A+

Laurent.

---
Laurent POINTAL - CNRS/LURE - Service Informatique Experiences
Tel/fax: 01 64 46 82 80 / 01 64 46 41 48
email  : pointal at lure.u-psud.fr  ou  lpointal at planete.net 



More information about the Python-list mailing list