[Numpy-discussion] int32 twice in sctypes?
oliphant at ee.byu.edu
Tue Nov 28 17:59:10 CST 2006
Matthew Brett wrote:
>I was a bit confused by this on 32 bit linux:
> <type 'numpy.int16'>,
> <type 'numpy.int32'>,
> <type 'numpy.int64'>,
> <type 'numpy.int32'>]
>Is it easy to explain the two entries for int32 here? I notice there
>is only one int32 entry for the same test on my 64 bit system.
The mapping from c-types to bit-width types is not one-to-one. All of
the c-types have their own array-scalar. Some of these have the same
bit-width and thus are named similarly.
numpy.int32 refers to exactly one of these c-types, but on some systems
(e.g. 32-bit), there will be another array scalar that also shows up
with the name numpy.int32
The easiest way to see them all is to observe
But then compare:
dtype('intp').type will be one of the above as can be verified by
The sctypes['int'] list is a list of all the c-type ints. Thus, you
could generate the id's of the first 5 typeobjects using:
[id(x) for x in sctypes['int']]
More information about the Numpy-discussion