Note On Mac OS X (and perhaps other platforms), executable files may be universal files containing multiple architectures.
To get at the “64-bitness” of the current interpreter, it is more reliable to query the sys.maxsize attribute:
is_64bits = sys.maxsize > 2**32
sys.maxsize> 2**32
only when 64-bit, so
$ python-32 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)'
('7fffffff', False)
$ $ python-64 -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)'
('7fffffffffffffff', True)
(As you said, this is not relatable, but there is no alternative I know.)
$ arch -x86_64 /usr/bin/python2.6 -c 'import sys,platform; print platform.architecture()[0], sys.maxsize > 2**32'
64bit True
$ $ arch -i386 /usr/bin/python2.6 -c 'import sys,platform; print platform.architecture()[0], sys.maxsize > 2**32'
64bit False
© 2024 OneMinuteCode. All rights reserved.