Permalink
Browse files

Added bitness and endianness

  • Loading branch information...
1 parent 85645cf commit e34171b4c54b8d731b8c1e95ef9c2331ef398478 @jterrace committed May 8, 2012
Showing with 29 additions and 1 deletion.
  1. +7 −0 README.rst
  2. +22 −1 its.py
View
7 README.rst
@@ -27,6 +27,13 @@ Usage is super simple::
>>> its.osx
True
+
+ >>> its.bit64
+ True
+
+ >>> its.little_endian
+ True
+
Installation
View
23 its.py
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
"""
-is.py
+its.py
~~~~~
System environment flags.
"""
import sys
+import struct
# -------
# Pythons
@@ -75,3 +76,23 @@
hpux = ('hpux' in str(sys.platform).lower()) # Complete guess.
solaris = ('solaris' in str(sys.platform).lower()) # Complete guess.
+
+# ---------
+# Bitness
+# ---------
+
+
+# 32-bit vs. 64-bit
+_void_ptr_size = struct.calcsize('P')
+bit32 = _void_ptr_size * 8 == 32
+bit64 = _void_ptr_size * 8 == 64
+
+
+# ---------
+# Endianness
+# ---------
+
+
+# little vs. big endian
+little_endian = sys.byteorder == 'little'
+big_endian = sys.byteorder == 'big'

0 comments on commit e34171b

Please sign in to comment.