I am using Python 3 with Google Colaboratory or the Coursera notebooks platform. I presume the problem would be the same with a local installation.
import numpy as np
def sum_numpy(N):
return np.sum(np.arange(N)**2)
def sum_python(N):
return sum([i**2 for i in range(N)])
sum_numpy(10**8) outputs 662921401752298880, and sum_python(10**8) outputs 333333328333333350000000
These functions give the same results with smaller numbers. For example, they both output 332833500 with 10**3.
Why don't they output the same result with 10**8 ? In theory, integers have no maximum in Python3.