7

I've installed Python 2.7 from the python-2.7.amd64.msi package from python.org. It installs and runs correctly, but seems to be in 32-bit mode, despite the fact that the installer was a 64 bit installer.

Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, platform
>>> platform.architecture()
('64bit', 'WindowsPE')
>>> sys.maxint
2147483647

What can I do to install Python so that it actually runs in 64-bit mode?

Bryan Catanzaro
  • 249
  • 1
  • 3
  • 10
  • 2
    In python 3.2 the sys.maxint constant was removed, since there is no longer a limit to the value of integers. However, sys.maxsize can be used as an integer larger than any practical list or string index. In python 3.2 32bit sys.maxsize is 2147483647, in python 3.2 64bit sys.maxsize is 9223372036854775807. – Czarek Tomczak Nov 16 '12 at 00:46

2 Answers2

14

See the discussion here. It's from 2.6.1, but it seems to still apply. I haven't seen evidence to the contrary anywhere, at least. The gist of the matter (quoted from that link) is:

This is by design. In their infinitive wisdom Microsoft has decided to make the 'long' C type always a 32 bit signed integer - even on 64bit systems. On most Unix systems a long is at least 32 bit but usually sizeof(ptr).

eldarerathis
  • 35,455
  • 10
  • 90
  • 93
  • Thanks for the pointer, I thought sys.maxint was a reliable way to check the bitness of the current Python interpreter. It's funny - on Mac OS X, platform.architecture() is wrong for me and sys.maxint is correct. But on Windows, it's evidently the reverse... Thanks again. – Bryan Catanzaro Aug 05 '10 at 05:11
  • Changing all of my values to explicit floats just made a bunch of the unit tests I wrote on a Linux system stop failing on my Windows machine. I totally owe you a drink. – hBy2Py Apr 25 '16 at 18:19
3

On my x86-64 Linux:

$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, platform
>>> platform.architecture()
('64bit', 'ELF')
>>> sys.maxint
9223372036854775807

Of course, what matters more than integer size is how much memory you can allocate. Maybe your smaller ints won't really matter much, since Python will just promote to a long any way, but if you can allocate more than three gigs of memory, you'll still be enjoying the benefits of 64 bit execution.

sarnold
  • 102,305
  • 22
  • 181
  • 238
  • I used python on 64 bit Windows, but I still got ` >>> sys.maxint 2147483647 >>> platform.architecture() ('64bit', 'WindowsPE') ` – Kimmi Dec 12 '14 at 18:04
  • @Kimmi, I think that can be explained by the `32` in the column `long (integer)`: http://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models – sarnold Dec 12 '14 at 23:32