[Numpy-discussion] What is a numpy.long type?

Chris Barker - NOAA Federal chris.barker@noaa....
Fri Aug 23 00:02:00 CDT 2013


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....

-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.Barker@noaa.gov


More information about the NumPy-Discussion mailing list