<div dir="ltr">On Wed, Jul 22, 2015 at 7:45 PM, <<a href="mailto:josef.pktd@gmail.com">josef.pktd@gmail.com</a>> wrote:<br>><br>> Is there an explanation somewhere of what different basic dtypes mean, across platforms and python versions?<br>><br>> >>> np.bool8<br>> <type 'numpy.bool_'><br>> >>> np.bool_<br>> <type 'numpy.bool_'><br>> >>> bool<br>> <type 'bool'><br>><br>><br>> Are there any rules and recommendations or is it all folks lore?<br><br>This may help a little:<div><br></div><div><a href="http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#arrays-dtypes-constructing">http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#arrays-dtypes-constructing</a></div><div><br></div><div>Basically, we accept the builtin Python type objects as a dtype argument and do something sensible with them. float -> np.float64 because Python floats are C doubles. int -> np.int32 or np.int64 depending on whatever a C long is (i.e. depending on the 64bitness of your CPU and how your OS chooses to deal with that). We encode those precision choices as aliases to the corresponding specific numpy scalar types (underscored as necessary to avoid shadowing builtins of the same name): np.float_ is np.float64, for example.</div><div><br></div><div>See here for why the aliases to Python builtin types, <a href="http://np.int">np.int</a>, np.float, etc. still exist:</div><div><br></div><div><a href="https://github.com/numpy/numpy/pull/6103#issuecomment-123652497">https://github.com/numpy/numpy/pull/6103#issuecomment-123652497</a><br><br>If you just need to pass a dtype= argument and want the precision that matches the "native" integer and float for your platform, then I prefer to use the Python builtin types instead of the underscored aliases; they just look cleaner. If you need a true numpy scalar type (e.g. to construct a numpy scalar object), of course, you must use one of the numpy scalar types, and the underscored aliases are convenient for that. Never use the aliases to the Python builtin types.<br><br>--<br>Robert Kern</div></div>