A plea for int overflow checking as the default

This is very late, but I currently spend some spare time reading about people’s issues with overflow (and behavior of languages).

from the Python ecosystem (mostly numpy & pandas)

While core Python expands integers to accommodate any integer and will not overflow, numpy’s arithmetic is modular when using integer types, and no error is raised on overflow. Therefore, the behaviour of NumPy and Python integer types differs significantly for integer overflows.

Pandas confirms that in general, neither pandas nor numpy check integer operations for overflow.

You can try
np.sum([2147483647,0], dtype=np.int32)
np.sum([2147483647,1], dtype=np.int32)

1 Like