Har Har - 24 days ago 9
Python Question

Entry message: [MSC v.1500 64 bit (AMD64)] on win32

I was wondering in, when I start python I get the following message:

Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>


I am using 64 bit python but why does it mention win32 as opposed to win64?

Answer Source

win32 is the general name for the Windows NT/95 API, whether you are on a 32-bit or 64-bit OS (or even using Win32s on a 16-bit OS).*

The 64 bit (AMD64) tells you that it is a 64-bit Python, built for a 64-bit Win32 OS, so everything is good.

The win32 is the same string that you see in sys.platform, which documents the strings you should see for each supported platform.

The [MSC v.1500 64 bit (AMD64)] identifies the compiler. On other platforms, Python doesn't cram the platform information into the compiler-name field.** But I guess they decided it was important, and there was nowhere else for it to go. :)

Anyway, the safe way to get this information is not to try to parse it out of the banner, but to use sys.maxsize.bit_length() > 32 on Python 3.x, or sys.maxsize > 2**32 on Python 2.x. (Note that platform.architecture specifically suggests that.)


* Why? Who knows. Some documentation does talk about "the Win32/Win64 API", although in most of the current docs they avoid that and say "the Windows API". This may be related to the fact that they have trademarks on "Win32", "Windows", and "Windows API", but not "Win64", "Win32 API", or "Win64 API"…

** Partly because it can't know that at compile time, if Python could be built as a universal binary for multiple architectures. For example, Python 2.7.6 on my Mac has both x86 and x86_64 code; it's 32-bit if I run the former, 64-bit if I run the latter. So the compiler just says [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)].