I learned how to use Numpy, and I wanted to see the difference in the speed of summing 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 sum of python_list is correct.
If I do the same code with a total of up to 1000, both print the correct answer. Is there an upper limit on the length of the Numpy array, or is it associated with the Numpy sum function?
thanks for the help
source
share