I need a way to tell what mode the shell is in from within the shell.
While I\'m primarily an OS X user, I\'d be interested in knowing about other platforms as well.<
platform.architecture()
is problematic (and expensive).
Conveniently test for sys.maxsize > 2**32
since Py2.6 .
This is a reliable test for the actual (default) pointer size and compatible at least since Py2.3: struct.calcsize('P') == 8
. Also: ctypes.sizeof(ctypes.c_void_p) == 8
.
Notes: There can be builds with gcc option -mx32
or so, which are 64bit architecture applications, but use 32bit pointers as default (saving memory and speed). 'sys.maxsize = ssize_t' may not strictly represent the C pointer size (its usually 2**31 - 1
anyway). And there were/are systems which have different pointer sizes for code and data and it needs to be clarified what exactly is the purpose of discerning "32bit or 64bit mode?"