"Overflowerror: Python Int Too Large to Convert to C Long" on Windows But Not MAC

OverflowError: Python int too large to convert to C long on windows but not mac

You'll get that error once your numbers are greater than sys.maxsize:

>>> p = [sys.maxsize]
>>> preds[0] = p
>>> p = [sys.maxsize+1]
>>> preds[0] = p
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C long

You can confirm this by checking:

>>> import sys
>>> sys.maxsize
2147483647

To take numbers with larger precision, don't pass an int type which uses a bounded C integer behind the scenes. Use the default float:

>>> preds = np.zeros((1, 3))

Python int too large to convert to C int

No. The variable is the type that it is. You can't set it to a value bigger than what it can hold. You'll have to live with a recursion depth of a mere two billion and change, instead of ten billion; I suspect you'll run out of memory before you get that many call frames deep anyway.



Related Topics



Leave a reply



Submit