Twenty quatloos says you're using numpy
's sum function:
>>> sum(xrange(10**7))
49999995000000L
>>> from numpy import sum
>>> sum(xrange(10**7))
-2014260032
So I'd bet you did from numpy import *
or are using some interface which does the equivalent.
To verify this, try
print type(sum(x))
On the example posted elsewhere in this thread:
>>> sum([721832253, 721832254, 721832254])
-2129470535
>>> type(sum([721832253, 721832254, 721832254]))
<type 'numpy.int32'>
Edit: somebody owes me twenty quatloos! Either don't use the star import (best), manually set the dtype
:
>>> sum([721832253, 721832254, 721832254],dtype=object)
2165496761L
or refer to the builtin sum
explicitly (possibly giving it a more convenient binding):
>>> __builtins__.sum([721832253, 721832254, 721832254])
2165496761L