On 30/09/2018 15:15, David Mertz wrote: > For similar reasons, I'd like an iInf too, FWIW. It's good for an > overflow value, although it's hard to get there in Python ints (would > 'NaNAwareInt(1)/0' be an exception or iInf?). Bonus points for anyone > who knows the actual maximum size of Python ints :-). > > However, the main use I'd have for iInf is simply as a starting value in > a minimization loop. E.g. > > minimum = NaNAwareInt('inf') > for i in the_data: > minimum = min(i, minimum) > > other_stuff(i, minimum, a, b, c) > > > I've written that code a fair number of times; usually I just pick a > placeholder value that is "absurdly large relative to my domain", but a > clean infinity would be slightly better. E.g. 'minimum = 10**100'. > The official maximum for a Python integer is x where x.bit_length()/8 == total_available_memory, (notice the word available which includes addressing limitations, other memory constraints, etc.).
Adding inf & -inf would be nice but to do so we would need a better name than NaNAwareInt. It would also be nice if Decimal(NaNAwareInt('nan')) = Decimal('NaN'), float(NaNAwareInt('nan')) = float('nan'), etc. I have been doing some reading up on Signalling vs. Quiet NaN and think that this convention could be well worth following, (and possibly storing some information about where the NaN was raised on first encountering a Signalling NaN (and converting it to Quiet). -- Steve (Gadget) Barnes Any opinions in this message are my personal opinions and do not reflect those of my employer. --- This email has been checked for viruses by AVG. https://www.avg.com _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/