[Numpy-discussion] numpy.int32 is not subclass of int, but numpy.int64 is

MACKEITH Andrew Andrew.MACKEITH at 3ds.com
Mon Nov 14 15:18:36 EST 2011


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.

Andrew

>python26
Python 2.6.2 (r262:71600, Jul  8 2010, 11:49:56)
[GCC 4.1.2 20070115 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import numpy
>>> a = numpy.array((1,2,3))
>>> type(a[0])
<type 'numpy.int64'>
>>> isinstance(a[0], int)
True
>>> isinstance(a[0], numpy.int)
True
>>> seven = numpy.int64(7)
>>> isinstance(seven, numpy.int)
True
>>> isinstance(seven, int)
True
>>>
>>> five = numpy.int32(5)
>>> isinstance(five, numpy.int)
False
>>> isinstance(five, int)
False
>>> five
5
>>> seven
7
>>> issubclass(numpy.int64, numpy.int)
True
>>> issubclass(numpy.int32, numpy.int)
False
>>>
>>> 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 email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email and all attachments,

(iii) Dassault Systemes does not accept or assume any liability or responsibility for any use of or reliance on this email.

For other languages, go to http://www.3ds.com/terms/email-disclaimer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20111114/a78ffc0a/attachment.html>


More information about the NumPy-Discussion mailing list