Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The question is somewhat ambiguous -- I'm not sure what you mean by "view". If you are trying to <em>query</em> the type of a native Python object, <a href="https://stackoverflow.com/questions/402504/how-to-determine-the-variable-type-in-python#402516">@atzz</a>'s answer will steer you in the right direction.</p> <p>However, if you are trying to <em>generate</em> Python objects that have the semantics of primitive C-types, (such as <code>uint32_t</code>, <code>int16_t</code>), use the <a href="http://docs.python.org/library/struct.html#struct.calcsize" rel="nofollow noreferrer"><code>struct</code></a> module. You can determine the number of bits in a given C-type primitive thusly:</p> <pre><code>&gt;&gt;&gt; struct.calcsize('c') # char 1 &gt;&gt;&gt; struct.calcsize('h') # short 2 &gt;&gt;&gt; struct.calcsize('i') # int 4 &gt;&gt;&gt; struct.calcsize('l') # long 4 </code></pre> <p>This is also reflected in the <code>array</code> module, which can make arrays of these lower-level types:</p> <pre><code>&gt;&gt;&gt; array.array('c').itemsize # char 1 </code></pre> <p>The maximum integer supported (Python 2's <code>int</code>) is given by <a href="http://docs.python.org/library/sys.html#sys.maxsize" rel="nofollow noreferrer">sys.maxint</a>.</p> <pre><code>&gt;&gt;&gt; import sys, math &gt;&gt;&gt; math.ceil(math.log(sys.maxint, 2)) + 1 # Signedness 32.0 </code></pre> <p>There is also <a href="http://docs.python.org/library/sys.html#sys.getsizeof" rel="nofollow noreferrer">sys.getsizeof</a>, which returns the actual size of the <em>Python</em> object in residual memory:</p> <pre><code>&gt;&gt;&gt; a = 5 &gt;&gt;&gt; sys.getsizeof(a) # Residual memory. 12 </code></pre> <p>For float data and precision data, use <a href="http://docs.python.org/library/sys.html#sys.float_info" rel="nofollow noreferrer">sys.float_info</a>:</p> <pre><code>&gt;&gt;&gt; sys.float_info sys.floatinfo(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.2204460492503131e-16, radix=2, rounds=1) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload