You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using C int default leads to overflow on 32-bit platforms #6056
In [2]: import numpy as np
In [3]: np.__version__
Out[3]: '1.10.0.dev0+b1a7d4c'
In [4]: np.prod((500, 500, 500, 500))
Out[4]: -1924509440
I assume this is because:
In [8]: np.array((500, 500, 500, 500)).dtype
Out[8]: dtype('int32')
Is there a good reason not to default to int64 int casting on 32 bit platforms? Is the speed difference large enough to justify this risk? Or is it the memory consumption?
The reason used to be that long is what pythons 2 int is, so we use that as default int (that way what you get subclasses python's int on python 2). Only addition/sums have an "upcast to 64 bit to be safe" logic.
Yeah, I think it might make sense to default to 64bits on all platforms (or at least on python 3).
EDIT: On windows you get int32 even if with 64 bit platform.
Activity
seberg commentedon Jul 9, 2015
The reason used to be that
longis what pythons 2 int is, so we use that as default int (that way what you get subclasses python'sinton python 2). Only addition/sums have an "upcast to 64 bit to be safe" logic.Yeah, I think it might make sense to default to 64bits on all platforms (or at least on python 3).
EDIT: On windows you get int32 even if with 64 bit platform.
jorenham commentedon Jul 22, 2026
This is no longer a problem :)