int/long unification hides bugs

Terry Reedy tjreedy at udel.edu
Tue Oct 26 00:09:53 EDT 2004


"kartik" <kartick_vaddadi at yahoo.com> wrote in message 
news:940ee3e8.0410251927.38347d92 at posting.google.com...
> 1)catching overflow bugs in the language itself frees u from writing
> overflow tests.

It is a fundamental characteristic of counts and integers that adding 1 is 
always valid.  Given that, raising an overflow exception is itself a bug, 
one that Python had and has now eliminated.

If one wishes to work with residue classes mod n, +1 is also still always 
valid.  It is just that (n-1) + 1 is 0 instead of n.  So again, raising an 
overflow error is a bug.

A number system that prohibits +1 for some fixed number n models, for 
instance, packing items into a container.  However, the limit n could be 
anything, so fixing it at, say, 2**31 - 1 is almost always useless.

The use of fixed range ints is a space-time machine performance hack that 
has been costly in human thought time.

Terry J. Reedy








More information about the Python-list mailing list