Python 2.x allows you to compare heterogeneous types.
A useful shortcut (in Python 2.7 here) is that None compared less than any integer or floating value:
>>> None < float('-inf') < -sys.maxint * 2l < -sys.maxint True
And in Python 2.7, an empty tuple () is an infinite value:
>>> () > float('inf') > sys.maxint True
This shortcut is useful when you can sort a mixed list of int and float and you want to have an absolute minimum and maximum for the link.
This shortcut was removed in Python 3000 (this is Python 3.2):
>>> None < 0 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unorderable types: NoneType() < int()
In addition, Python3000 removed sys.maxint on the theory that all ints are pushed to long, and the limit is no longer applied.
PEP 326 , an example for upper and lower values, produced a min and max link in Python. New ordered behavior is documented .
Since PEP 326 was rejected, what are some useful, usable definitions for the min and max values ββthat work with integers and floats and longs in Python 2X and Python 3000?
Edit
Several answers go along the lines of "just use maxv = float (" inf ")" ... The reason why I think as much as possible is this:
>>> float(2**5000) Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: long int too large to convert to float
and
>>> cmp(1.0**4999,10.0**5000) Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: (34, 'Result too large')
However:
>>> () > 2**5000 True
In order for cmp to reach the value of float, float('inf') , the long value would need to be converted to float, and the conversion would raise OverflowError ...
Conclusion
Thank you all for your answers and comments. I chose the TryPyPy answer because it seemed the most embedded in what I asked: the absolute largest and absolute smallest value, as described on Wikipedia's entry for infinity.
With this question, I found out that the value of long or int is not converted to float to complete the comparison float('inf') > 2**5000 . I did not know that.