How to avoid overflow errors

Paul Rubin http
Fri Sep 14 21:08:00 EDT 2007


"Eduardo O. Padoan" <eduardo.padoan at gmail.com> writes:
> Not totally unrelated, but in Py3k, as it seems, overflows are really
> things of the past:
> 
> 
> Python 3.0a1 (py3k:58061, Sep  9 2007, 13:18:37)
> [GCC 4.1.3 20070831 (prerelease) (Ubuntu 4.1.2-16ubuntu1)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> class MyInt(int):
> ...     pass
> ...
> >>> import sys
> >>> MyInt(sys.maxint)
> 2147483647
> >>> MyInt(sys.maxint+1)
> 2147483648

I'd be interested in knowing what happens in 3.0a1 with

  a = itertools.count(sys.maxint)
  print a.next()
  print a.next()



More information about the Python-list mailing list