471,357 Members | 1,090 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

determine 32 or 64 bit architecture with python 2.2

Hello,
how can I determine the architecture (32 or 64bit) with python 2.2 on
Windows or Unix (AIX, Solaris) OS, without the modul platform?
Thanks for your hints, Kai

Jun 19 '07 #1
6 4803
On Jun 19, 9:17 pm, Kai Rosenthal <kairosent...@tiscali.dewrote:
Hello,
how can I determine the architecture (32 or 64bit) with python 2.2 on
Windows or Unix (AIX, Solaris) OS, without the modul platform?
Thanks for your hints, Kai
What happens when you fire up a 64-bit Python and type
import sys; sys.maxint
at it?

Jun 19 '07 #2
On Jun 19, 4:28 pm, John Machin <sjmac...@lexicon.netwrote:
On Jun 19, 9:17 pm, Kai Rosenthal <kairosent...@tiscali.dewrote:
Hello,
how can I determine the architecture (32 or 64bit) with python 2.2 on
Windows or Unix (AIX, Solaris) OS, without the modul platform?
Thanks for your hints, Kai

What happens when you fire up a 64-bit Python and type
import sys; sys.maxint
at it?
That's not suitable, because of the differences between LP64 and LLP64
(http://en.wikipedia.org/wiki/64-bit#64-bit_data_models ).

Try
python -c "import struct; print struct.calcsize('P')"
instead. That calculates the size of a pointer.

Jun 19 '07 #3
David Rushby wrote:
On Jun 19, 4:28 pm, John Machin <sjmac...@lexicon.netwrote:
>On Jun 19, 9:17 pm, Kai Rosenthal <kairosent...@tiscali.dewrote:
>>Hello,
how can I determine the architecture (32 or 64bit) with python 2.2 on
Windows or Unix (AIX, Solaris) OS, without the modul platform?
Thanks for your hints, Kai
What happens when you fire up a 64-bit Python and type
import sys; sys.maxint
at it?

That's not suitable, because of the differences between LP64 and LLP64
(http://en.wikipedia.org/wiki/64-bit#64-bit_data_models ).

Try
python -c "import struct; print struct.calcsize('P')"
instead. That calculates the size of a pointer.
How about:

tuple.__itemsize__

since each tuple item is a pointer.

--
Lenard Lindstrom
<le***@telus.net>
Jun 19 '07 #4
Kai Rosenthal schrieb:
how can I determine the architecture (32 or 64bit) with python 2.2 on
Windows or Unix (AIX, Solaris) OS, without the modul platform?
On Windows, the architecture is always 32-bit, as Python 2.2 does not
support Win64. On Unix, looking for sys.maxint is enough for AIX
and Solaris.

Regards,
Martin
Jun 20 '07 #5
>What happens when you fire up a 64-bit Python and type
> import sys; sys.maxint
at it?

That's not suitable, because of the differences between LP64 and LLP64
(http://en.wikipedia.org/wiki/64-bit#64-bit_data_models ).
For the systems that the OP mentioned, sys.maxint is just fine:
AIX and Solaris both use LP64, and Windows is 32-bit only for
Python 2.2.

Regards,
Martin
Jun 20 '07 #6
On 6/19/07, Kai Rosenthal <ka**********@tiscali.dewrote:
Hello,
how can I determine the architecture (32 or 64bit) with python 2.2 on
Windows or Unix (AIX, Solaris) OS, without the modul platform?
Thanks for your hints, Kai
For Unix systems you can probably use os.uname() and check what
architecture the kernel is built for. For example,

evan@thinkpad ~ $ python -c 'import os; print os.uname()[4]'
i686

As you can see, I'm on a 32 bit system.

--
Evan Klitzke <ev**@yelp.com>
Jun 20 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by ketulp_baroda | last post: by
9 posts views Thread by Lenard Lindstrom | last post: by
15 posts views Thread by limeydrink | last post: by
7 posts views Thread by Samuel | last post: by
varuns
1 post views Thread by varuns | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.