[Tutor] How to check the word size of the platform(OS)?
Steven D'Aprano
steve at pearwood.info
Sun Aug 3 05:41:15 CEST 2014
On Sat, Aug 02, 2014 at 06:32:31PM +0530, Varuna Seneviratna wrote:
> What is the way to check the word size of the platform(OS), and also int
> size and character size, are they the same. I searched on line But couldn't
> get an answer
You can get some platform details from the platform module:
https://docs.python.org/2/library/platform.html
but why do you need these details? Python is a high-level
object-oriented language, not a low-level language like C, and native
machine types aren't very often relevant. For example, Python ints are
not the same as native ints, they are "Big Num" objects of unlimited
size:
py> sys.getsizeof(23) # returns number of bytes used
12
py> sys.getsizeof(2**30000)
4014
Just about the only things I can think of where I might want to know
these sorts of low-level platform details can be handled by the struct
module:
https://docs.python.org/2/library/struct.html
If you explain what you want to do in more detail, perhaps we can help
with a better answer.
--
Steven
More information about the Tutor
mailing list