[CentralOH] Python bit size

Eric Floehr eric at intellovations.com
Wed May 11 01:18:52 CEST 2011


Mark,

Yes, but actually substitute sys.maxsize for sys.maxint for Python 3
compatibility.

sys.maxsize (for CPython at least) is size_t of the compiler it was compiled
with, which basically means it's supported "bitness".

-Eric


On Tue, May 10, 2011 at 7:03 PM, Mark Erbaugh <mark at microenh.com> wrote:

>
>
> Sent from my iPad
>
> On May 10, 2011, at 3:45 PM, Eric Floehr <eric at intellovations.com> wrote:
>
> > I think your answer is right there (sys.maxint):
> >
> > def bits():
> >     import sys
> >     x = sys.maxint
> >     n = 1
> >     while x:
> >         n += 1
> >         x >>= 1
> >     return n
> >
> > -Eric
>
> Is that always guaranteed that the size of an int is the sizeof the Python
> bits?
>
> Mark
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> http://mail.python.org/mailman/listinfo/centraloh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/centraloh/attachments/20110510/6a6beb4a/attachment.html>


More information about the CentralOH mailing list