[Numpy-discussion] how to ask numpy what bit version it is running (32/64)

Mark Wiebe mwwiebe@gmail....
Tue Oct 19 22:03:00 CDT 2010


What about this as a possibility:

>>> numpy.intp(0).itemsize == 8
True

-Mark

On Tue, Oct 19, 2010 at 7:11 PM, Vincent Davis <vincent@vincentdavis.net>wrote:

> A little followup from the python list. I thought this was worth sharing
> here.
>
> Quoting Ned Deily, nad@acm.org
>
> "
> It looks better but <refering to print platform.architecture()>,
> unfortunately, it doesn't work correctly on OS X
> where a universal build can have both 32-bit and 64-bit executables in
> the same file.
>
> $ arch -x86_64 /usr/local/bin/python2.7 -c 'import sys,platform;
> print(sys.maxint,platform.architecture())'
> (9223372036854775807, ('64bit', ''))
> $ arch -i386 /usr/local/bin/python2.7 -c 'import sys,platform;
> print(sys.maxint,platform.architecture())'
> (2147483647, ('64bit', ''))
>
> At the moment, the sys.maxint trick is the simplest reliable test for
> Python 2 on OS X.  For Python 3, substitute sys.maxsize.
>
> > Yes that looks like the right way of doing it. Interesting though that
> > platform.machine()=i386 and not something about 64.
> > >>> print platform.machine()
> > i386
> > >>> print platform.architecture()
> > ('64bit', '')
> > >>> import sys; sys.maxint
> > 9223372036854775807
>
> Currently on OS X (10.6 and earlier), uname returns 'i386' for any Intel
> platform, 32-bit only or 32-bit /64-bit capable.
>
> $ uname -p
> i386
> "
>
> On Tue, Oct 19, 2010 at 4:25 PM, Vincent Davis <vincent@vincentdavis.net>
> wrote:
> > On Tue, Oct 19, 2010 at 4:13 PM, Jonathan Rocher <jrocher@enthought.com>
> wrote:
> >> Hi,
> >>
> >> If you directly want to know if it is a 32 or 64 bits, you can also use
> >> import platform
> >> print platform.architecture()
> >>
> >> Best,
> >> Jonathan
> >>
> >> On Tue, Oct 19, 2010 at 5:09 PM, David Cournapeau <cournape@gmail.com>
> >> wrote:
> >>>
> >>> On Wed, Oct 20, 2010 at 6:54 AM, Vincent Davis <
> vincent@vincentdavis.net>
> >>> wrote:
> >>> > What is the best/good way to know what version of numpy is running
> (32
> >>> > or 64 bit).
> >>>
> >>> import platform
> >>> print platform.machine()
> >>>
> >>> > Showing my ignorance maybe but does it always match the python
> version
> >>> > that is running, which can be ask/tested using sys.maxint?
> >>>
> >>> Yes, I don't know any system which enables you do load a 32 bits
> >>> extension into a 64 bits. Neither windows, mac or linux can at least,
> >>>
> >>> cheers,
> >>>
> >>> David
> >
> > on python27 64 bit
> > import platform
> > print platform.machine()
> > i386
> > print platform.architecture()
> > ('64bit', '')
> > sys.maxint
> > 9223372036854775807
> >
> > on python2.6 32bit
> >>>> import platform
> >>>> print platform.machine()
> > i386
> >>>> print platform.architecture()
> > ('32bit', '')
> > sys.maxint
> > 2147483647
> >
> > And given David's answers if python is 64(or 32) then numpy/scipy is
> > the same or not working :-)
> >
> > Thanks
> > Vincent
> >
> >
> >>>>
> >
> >>> _______________________________________________
> >>> NumPy-Discussion mailing list
> >>> NumPy-Discussion@scipy.org
> >>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >>
> >>
> >>
> >> --
> >> Jonathan Rocher,
> >> Enthought, Inc.
> >> jrocher@enthought.com
> >> 1-512-536-1057
> >> http://www.enthought.com
> >>
> >>
> >> _______________________________________________
> >> NumPy-Discussion mailing list
> >> NumPy-Discussion@scipy.org
> >> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >>
> >>
> >
> >
> >
> > --
> > Thanks
> > Vincent Davis
> > 720-301-3003
> >
>
>
>
> --
> Thanks
> Vincent Davis
> 720-301-3003
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101019/967eae98/attachment.html 


More information about the NumPy-Discussion mailing list