24

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?

jww
  • 97,681
  • 90
  • 411
  • 885
Har
  • 3,727
  • 10
  • 41
  • 75
  • PS, thanks for this question; I was just trying to remember what the compiler string looks like on Windows yesterday, and my Windows VM is out of disk space. :) – abarnert Apr 20 '15 at 10:49

2 Answers2

30

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)].

arshovon
  • 13,270
  • 9
  • 51
  • 69
abarnert
  • 354,177
  • 51
  • 601
  • 671
  • that's interesting since on Linux I get the following:[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)] on linux2 it says linux 2 which probably means the linux 2 api? – Har Apr 20 '15 at 10:34
  • 1
    @Har: Yeah, to switch on platform/uname you always have to test `u.startswith('linux')` (and `u.lower()=='cygwin'`, for extra fun), as opposed to just `u=='win32'` and `u=='darwin'`. – abarnert Apr 20 '15 at 10:37
  • Although I think `linux2` originally meant any linux kernel with glibc 2.3+, as opposed to `linux`, which was linux with glibc 2.2. Then at some point it changed to be `linux2` or `linux3` depending on the kernel (based on whatever `uname -s` plus `uname -r` returns), then always `linux2` no matter what, and eventually they decided (in 3.3+) to just call all of them `linux`. – abarnert Apr 20 '15 at 10:41
4

It just means for the windows platform, not that your architecture is 32 bit . The MSC v.1500 64 bit (AMD64) means it is compiled as a 64 bit application.

Padraic Cunningham
  • 176,452
  • 29
  • 245
  • 321