But Python integers are variable-sized, and their size is basically limited by available memory or address space.
Let's take a typical 64-bit Python build, assuming 4 GB RAM available. Let's also assume that 90% of those 4 GB can be readily allocated for Python objects (there's overhead, etc.). Also let's take a look at the Python integer representation: >>> sys.int_info sys.int_info(bits_per_digit=30, sizeof_digit=4) This means that every 4 bytes of integer object store 30 bit of actual integer data. So, how many bits has the largest allocatable integer on that system, assuming 90% of 4 GB are available for allocation? >>> nbits = (2**32)*0.9*30/4 >>> nbits 28991029248.0 Now how many possible integers are there in that number of bits? >>> x = 1 << int(nbits) >>> x.bit_length() 28991029249 (yes, that number was successfully allocated in full. And the Python process occupies 3.7 GB RAM at that point, which validates the estimate.) Let's try to have a readable approximation of that number. Convert it to a float perhaps? >>> float(x) Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: int too large to convert to float Well, of course. So let's just extract a power of 10: >>> math.log10(x) 8727169408.819794 >>> 10**0.819794 6.603801339268099 (yes, math.log10() works on non-float-convertible integers. I'm impressed!) So the number of representable integers on that system is approximately 6.6e8727169408. Let's hope the Sun takes its time. (and of course, what is true for ints is true for any variable-sized input, such as strings, lists, dicts, sets, etc.) Regards Antoine. Le 29/11/2018 à 00:24, David Mertz a écrit : > That's easy, Antoine. On a reasonable modern multi-core workstation, I > can do 4 billion additions per second. A year is just over 30 million > seconds. For 32-bit ints, I can whiz through the task in only 130,000 > years. We have at least several hundred million years before the sun > engulfs us. > > On Wed, Nov 28, 2018, 5:09 PM Antoine Pitrou <solip...@pitrou.net > <mailto:solip...@pitrou.net> wrote: > > On Wed, 28 Nov 2018 15:58:24 -0600 > Abe Dillon <abedil...@gmail.com <mailto:abedil...@gmail.com>> wrote: > > Thirdly, Computers are very good at exhaustively searching > multidimensional > > spaces. > > How long do you think it will take your computer to exhaustively search > the space of possible input values to a 2-integer addition function? > > Do you think it can finish before the Earth gets engulfed by the Sun? > > Regards > > Antoine. > > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org <mailto:Python-ideas@python.org> > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/