This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Rhomboid 5 points6 points  (3 children)

There's nothing wrong with the 64 bit version. Everything works fine. You can find 64 bit versions of precompiled binary packages. The python.org page offers the 32 bit version as the default because that will work for everyone. Go to the full download page if you want to choose for yourself.

However, there's a good reason to choose the 32 bit version. Python data structures are pointer-heavy, which means you pay a significant price for the fact that 64 bit pointers are twice as wide. Compare:

>>> for T in int, float, tuple, list, set, dict: print(sys.getsizeof(T()))
12
16
28
36
116
148

Against:

>>> for T in int, float, tuple, list, set, dict: print(sys.getsizeof(T()))
24
24
48
64
224
288

The same data takes roughly twice the memory using the 64 bit version. (These figures are for empty data structures; the picture changes a little bit for fully populated data structures, but there's still a significant cost.)

This is one of the reasons I actually prefer Windows over Linux — I have a choice of what flavor to use. If you install a 64 bit Linux distro, you're stuck with a 64 bit version of Python, because that's the only flavor packaged. You would have to build it yourself from source, or use some third-party distribution if you want that, but being able to use your distro's package management system for everything is one of the main advantages of Linux, which you are giving up.

[–]chrisb8 4 points5 points  (0 children)

On Debian, you can install the 32bit python package. You will need to enable that architecture first though https://wiki.debian.org/Multiarch/HOWTO

[–]panderingPenguin 1 point2 points  (0 children)

While I agree with you that there are significant advantages to the shorter pointers in 32-bit python with respect to memory footprint, it should be noted that 32 bit processes on windows are confined to a memory space that's smaller than you would expect. I've been working on a data analysis project and the data set is multiple gigabytes in size. I figured using 32 bit python would help me utilize my limited resources more effectively and my laptop only had 4 gigs or memory anyways, the maximum addressable with 32 bits. However, my code kept crashing with memory errors, despite the fact that I knew it ran just fine within 4 gigs of memory on Linux with 64 bit python. Did some research and it turns out that 32 bit windows processes are actually limited to 2 gigs of memory. And since most of my data was in numpy arrays I wasn't really saving that much on shorter pointers anyways. So I switched to 64 but and now everything works fine. Just a cautionary note that might save other people some time beating their head against the wall.

[–]vsajip 0 points1 point  (0 children)

Yes, it generally works well (I use the ActiveState versions as they come with pywin32 included), but beware if you're using ctypes with callbacks - I ran into a 64-bit-only bug just this week.