Numpy: Is there an array size limit?

numpy, python

Solution

Numpy is creating an array of 32-bit unsigned ints. When it sums them, it sums them into a 32-bit value.

if 499999500000L % (2**32) == 1783293664L:
    print "Overflowed a 32-bit integer"

You can explicitly choose the data type at array creation time:

a = numpy.arange(1000000, dtype=numpy.uint64)
a.sum() -> 499999500000

Problem

I'm learning to use Numpy and I wanted to see the speed difference in the summation of a list of numbers so I made this code: ``` np_array = numpy.arange(1000000) start = time.time() sum_ = np_array.sum() print time.time() - start, sum_ >>> 0.0 1783293664 python_list = range(1000000) start = time.time() sum_ = sum(python_list) print time.time() - start, sum_ >>> 0.390000104904 499999500000 ``` The python_list sum is correct. If I do the same code with the summation to 1000, both print the right answer. Is there an upper limit to the length of the Numpy array or is it with the Numpy sum function? Thanks for your help

Original source