On Fri, Aug 23, 2013 at 6:02 AM, Chris Barker - NOAA Federal < chris.bar...@noaa.gov> wrote:
> 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 long: arch -32 python -c "import numpy as np; print np.dtype(np.int); print np.dtype(np.long)" int32 int64 arch -64 python -c "import numpy as np; print np.dtype(np.int); print np.dtype(np.long)" int64 int64 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). David > > -Chris > > > > > -- > > Christopher Barker, Ph.D. > Oceanographer > > 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 > > chris.bar...@noaa.gov > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion