Are there standard ways to determine things like wordlength etc in distutils? I suppose one can use sys.maxint, but I thought this might be a standard kind of requirement now that we're slipping from 32 to 64 bits. -- Robin Becker
Robin Becker wrote:
Are there standard ways to determine things like wordlength etc in distutils?
I suppose one can use sys.maxint, but I thought this might be a standard kind of requirement now that we're slipping from 32 to 64 bits.
I'd use the struct module for these things. -- Marc-Andre Lemburg eGenix.com Professional Python Software directly from the Source (#1, Jun 29 2003)
Python/Zope Products & Consulting ... http://www.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
In article <3EFF188F.3020607@lemburg.com>, M.-A. Lemburg <mal@lemburg.com> writes
Robin Becker wrote:
Are there standard ways to determine things like wordlength etc in distutils?
I suppose one can use sys.maxint, but I thought this might be a standard kind of requirement now that we're slipping from 32 to 64 bits.
I'd use the struct module for these things.
So we assume struct units are 8 bits and then use calcsize("i")*8 as the wordlength. -- Robin Becker
Robin Becker wrote:
In article <3EFF188F.3020607@lemburg.com>, M.-A. Lemburg <mal@lemburg.com> writes
Robin Becker wrote:
Are there standard ways to determine things like wordlength etc in distutils?
I suppose one can use sys.maxint, but I thought this might be a standard kind of requirement now that we're slipping from 32 to 64 bits.
I'd use the struct module for these things.
So we assume struct units are 8 bits and then use calcsize("i")*8 as the wordlength.
sizeofint = len(struct.pack('i',1)) -- Marc-Andre Lemburg eGenix.com Professional Python Software directly from the Source (#1, Jun 29 2003)
Python/Zope Products & Consulting ... http://www.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
Jeremy Hylton wrote:
On Sun, 2003-06-29 at 14:14, M.-A. Lemburg wrote:
So we assume struct units are 8 bits and then use calcsize("i")*8 as the wordlength.
sizeofint = len(struct.pack('i',1))
Why not
sizeofint = struct.calcsize("i")
?
Even better :-) -- Marc-Andre Lemburg eGenix.com Professional Python Software directly from the Source (#1, Jun 30 2003)
Python/Zope Products & Consulting ... http://www.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
In article <3F009A40.1040303@lemburg.com>, M.-A. Lemburg <mal@lemburg.com> writes
Jeremy Hylton wrote:
On Sun, 2003-06-29 at 14:14, M.-A. Lemburg wrote:
So we assume struct units are 8 bits and then use calcsize("i")*8 as the wordlength.
sizeofint = len(struct.pack('i',1))
Why not
sizeofint = struct.calcsize("i")
?
Even better :-)
well if I wish to store 4 bits/int then this works
import struct print struct.calcsize("i") 4
but I assume we can store more than 4 bits per int, so waht tells us we cans store 8 bits/struct unit? -- Robin Becker
Robin Becker wrote:
sizeofint = struct.calcsize("i")
well if I wish to store 4 bits/int then this works
s/bits/bytes calcsize returns the number of 8-bit characters the format string needs to store the given C types.
import struct print struct.calcsize("i")
4
but I assume we can store more than 4 bits per int, so waht tells us we cans store 8 bits/struct unit?
characters map to 8 bits == 1 byte and it's rather unlikely that a C compiler will use a different mapping any time soon. -- Marc-Andre Lemburg eGenix.com Professional Python Software directly from the Source (#1, Jul 01 2003)
Python/Zope Products & Consulting ... http://www.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
In article <3F0134E4.10907@lemburg.com>, M.-A. Lemburg <mal@lemburg.com> writes ......
characters map to 8 bits == 1 byte and it's rather unlikely that a C compiler will use a different mapping any time soon.
that's what I thought, but it's wise to be sure, and though I suppose there are few Pdp-18's or CDC 6000's running these days, it doesn't seem unreasonable given the changes over the last 20 years that unicode of 16/32 bits might become more acceptable as a 'char unit'. -- Robin Becker
participants (3)
-
Jeremy Hylton
-
M.-A. Lemburg
-
Robin Becker