[Numpy-discussion] What is a numpy.long type?
Fri Aug 23 01:57:16 CDT 2013
On Fri, Aug 23, 2013 at 6:02 AM, Chris Barker - NOAA Federal <
> Hi folks,
> I had thought that maybe a numpy.long dtype was a system
> (compiler)-native C long.
> But on both 32 and 64 bit python on OS-X, it seems to be 64 bit. I'm
> pretty sure that on OS-X 32 bit, a C long is 32 bits. (gdd, of course)
> I don't have other machines to test on , but as the MS compilers and
> gcc do different things with a C long on 64 bit platforms, I"m curious
> how numpy defines it.
> In general, I prefer the "explicit is better than implicit" approach
> and use, e.g. int32 and int64. However, in this case, we are using
> Cython, and calling C code that used "long" -- so what I want is
> "whatever the compiler thinks is a long" -- is there a way to do that
> without my own kludgy platform-dependent code?
> I note that the Cython numpy.pxd assigns:
> ctypedef signed long npy_long
> Is that a bug? (or maybe npy_long is not supposed to match np.long....
npy_long is indeed just an alias to C long, np.long is an alias to python's
arch -32 python -c "import numpy as np; print np.dtype(np.int); print
arch -64 python -c "import numpy as np; print np.dtype(np.int); print
and python -c "import numpy as np; print np.long is long" will print True
All this is on python 2.7, I am not sure how/if that changes on python 3
(that consolidated python int/long).
> Christopher Barker, Ph.D.
> Emergency Response Division
> NOAA/NOS/OR&R (206) 526-6959 voice
> 7600 Sand Point Way NE (206) 526-6329 fax
> Seattle, WA 98115 (206) 526-6317 main reception
> NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion