Skip to content Skip to sidebar Skip to footer

Python - Check If A System Is 32 Or 64 Bit To Determine Whether To Run The Function Or Not?

Possible Duplicate: How do I determine if my python shell is executing in 32bit or 64bit mode? I made a question earlier that never got replied to, but I have something more spe

Solution 1:

Following this documentation, try this code:

is_64bits = sys.maxsize > 2**32

Note: this can return an incorrect result if 32bit Python is running on a 64bit operating system.

Solution 2:

An alternative method. Definitely works on all platforms:

importstructis_64bit = struct.calcsize('P') * 8 == 64

As a note, this is part of its.py.

Post a Comment for "Python - Check If A System Is 32 Or 64 Bit To Determine Whether To Run The Function Or Not?"