Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added bitness and endianness

  • Loading branch information...
commit e34171b4c54b8d731b8c1e95ef9c2331ef398478 1 parent 85645cf
Jeff Terrace authored May 08, 2012

Showing 2 changed files with 29 additions and 1 deletion. Show diff stats Hide diff stats

  1. 7  README.rst
  2. 23  its.py
7  README.rst
Source Rendered
@@ -27,6 +27,13 @@ Usage is super simple::
27 27
 
28 28
     >>> its.osx
29 29
     True
  30
+    
  31
+    >>> its.bit64
  32
+    True
  33
+    
  34
+    >>> its.little_endian
  35
+    True
  36
+
30 37
 
31 38
 
32 39
 Installation
23  its.py
... ...
@@ -1,7 +1,7 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3 3
 """
4  
-is.py
  4
+its.py
5 5
 ~~~~~
6 6
 
7 7
 System environment flags.
@@ -9,6 +9,7 @@
9 9
 
10 10
 
11 11
 import sys
  12
+import struct
12 13
 
13 14
 # -------
14 15
 # Pythons
@@ -75,3 +76,23 @@
75 76
 hpux = ('hpux' in str(sys.platform).lower())   # Complete guess.
76 77
 solaris = ('solaris' in str(sys.platform).lower())   # Complete guess.
77 78
 
  79
+
  80
+# ---------
  81
+# Bitness
  82
+# ---------
  83
+
  84
+
  85
+# 32-bit vs. 64-bit
  86
+_void_ptr_size = struct.calcsize('P')
  87
+bit32 = _void_ptr_size * 8 == 32
  88
+bit64 = _void_ptr_size * 8 == 64
  89
+
  90
+
  91
+# ---------
  92
+# Endianness
  93
+# ---------
  94
+
  95
+
  96
+# little vs. big endian
  97
+little_endian = sys.byteorder == 'little'
  98
+big_endian = sys.byteorder == 'big'

0 notes on commit e34171b

Please sign in to comment.
Something went wrong with that request. Please try again.