[Numpy-discussion] dtype and dtype.char

Robert Kern robert.kern at gmail.com
Tue Sep 8 16:02:20 EDT 2009


2009/9/8 Charles سمير Doutriaux <doutriaux1 at llnl.gov>:
> Hi,
>
> I'm testing our code on 64bit vs 32bit
>
> I just realized that the dtype.car is platform dependent.
>
> I guess it's normal
>
> her emy little test:
> for t in
> [numpy
> .byte
> ,numpy
> .short
> ,numpy
> .int
> ,numpy
> .int32
> ,numpy
> .float
> ,numpy
> .float32
> ,numpy
> .double,numpy.ubyte,numpy.ushort,numpy.uint,numpy.int64,numpy.uint64]:
>     print 'Testing type:',t
>     data = numpy.array([0], dtype=t)
>     print data.dtype.char,data.dtype
>
>
> On 64bit I get for numpy.unit64:
> Testing type: <type 'numpy.uint64'>
> L uint64
>
> Whereas on 32bit i get
> Testing type: <type 'numpy.uint64'>
> Q uint64
>
> Is it really normal? I guess that means I shouldn't expect the
> dtype.char to be the same on all platform....
>
> Is that right?

Yes. dtype.char corresponds more closely to the C type ("L" ==
"unsigned long" and "Q" == "unsigned long long") which is platform
specific.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list