I have some code like:
import math, csv, sys, re, time, datetime, pickle, os, gzip
from numpy import *
x = [1, 2, 3, ... ]
y = sum(x)
The sum of the actual values in x
is 2165496761, which is larger than the limit of 32bit integer. The reported y
value is -2129470535
, implying integer overflow.
Why did this happen? I thought the built-in sum
was supposed to use Python's arbitrary-size integers?
See How to restore a builtin that I overwrote by accident? if you've accidentally done something like this at the REPL (interpreter prompt).