32bit integers as list indices

Travis Oliphant oliphant at ee.byu.edu
Tue Nov 14 09:56:14 CST 2006

Neilen Marais wrote:

>I'm not sure if the following is expected to work on a 64bit machine:
>In [381]: import numpy as N
>In [382]: l = range(3)
>In [383]: i32 = N.array([0,2], N.int32)
>In [384]: i64 = N.array([0,2], N.int64)
>In [385]: l[i32[0]]
>exceptions.TypeError                           Traceback (most recent call last)
>/home/brick/akademie/NewCode/working/<ipython console> 
>TypeError: list indices must be integers
>In [386]: l[i64[0]]
>Out[386]: 0
>I'd expect the 32-bit indices to work since they can be upcast to 64bit without
>loss. Am I silly for thinking this way, or is it something numpy can/should
>address? This came up while working with sparse matrices:

It's addressed with Python 2.5  

We can't do anything about it for Python 2.4


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

More information about the Numpy-discussion mailing list