[Numpy-discussion] numpy.int32 is not subclass of int, but numpy.int64 is
Robert Kern
robert.kern@gmail....
Mon Nov 14 14:25:41 CST 2011
On Mon, Nov 14, 2011 at 20:18, MACKEITH Andrew <Andrew.MACKEITH@3ds.com> wrote:
> Could someone explain this?
>
> An instance of numpy.int32 is not an instance of int or numpy.int.
> An instance of numpy.int64 is an instance of int and numpy.int.
>
> I don't know if it is a bug in my linux build.
>>>> import sys
>>>> sys.maxint
> 9223372036854775807
>>>> import platform
>>>> print platform.platform()
> Linux-2.6.32.12-0.7-default-x86_64-with-SuSE-11-x86_64
This is expected on a 64-bit platform. Note that numpy.int is just an
alias for the builtin int type for backwards compatibility with an
earlier version of numpy. We could probably remove it, since it seems
to be causing more confusion than not.
Anyways, we subclass the appropriately sized integer scalar type from
Python's int type depending on the platform. So on a platform where
Python's int type is 64-bits, numpy.int64 will include int in its
inheritance tree. On platforms where the Python int type is 32-bit,
numpy.int32 will include it instead.
--
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