How to make an integer larger than any other integer?
<p>Note: while the accepted answer achieves the result I wanted, and @ecatmur answer provides a more comprehensive option, I feel it's very important to emphasize that my use case is a bad idea in the first place. This is explained very well in <a href="http://stackoverflow.com/a/39856605/336527">@Jason Orendorff answer below</a>.</p>

<p>Note: this question is not a duplicate of <a href="http://stackoverflow.com/questions/13795758/what-is-sys-maxint-in-python-3">the question about <code>sys.maxint</code></a>. It has nothing to do with <code>sys.maxint</code>; even in python 2 where <code>sys.maxint</code> is available, it does NOT represent largest integer (see the accepted answer).</p>

<p>I need to create an integer that's larger than any other integer, meaning an <code>int</code> object which returns <code>True</code> when compared to any other <code>int</code> object using <code>&gt;</code>. Use case: library function expects an integer, and the only easy way to force a certain behavior is to pass a very large integer.</p>

<p>In python 2, I can use <code>sys.maxint</code> (edit: I was wrong). In python 3, <code>math.inf</code> is the closest equivalent, but I can't convert it to <code>int</code>.</p>

<p>It seems to me that this would be fundamentally impossible. Let's say you write a function that returns this RBI ("really big int"). If the computer is capable of storing it, then someone else could write a function that returns the same value. Is your RBI greater than itself?</p>

<p>Perhaps you can achieve the desired result with something like @wim's answer: Create an object that overrides the comparison operators to make "&lt;" always return false and ">" always return true. (I haven't written a lot of Python. In most object-oriented languages, this would only work if the comparison puts your value first, IF RBI>x. If someone writes the comparison the other way, IF x>RBI, it will fail because the compiler doesn't know how to compare integers to a user-defined class.)</p>

python python-3.x