[Python-ideas] Infinite in Python (not just in datetime)

Andrew Barnert abarnert at yahoo.com
Mon Feb 2 19:10:32 CET 2015


On Feb 2, 2015, at 10:03, MRAB <python at mrabarnett.plus.com> wrote:

> On 2015-02-02 16:45, Chris Barker wrote:
>> On Mon, Feb 2, 2015 at 7:27 AM, Thomas Güttler
>> <guettliml at thomas-guettler.de <mailto:guettliml at thomas-guettler.de>> wrote:
>> 
>>        Infinite what?
>> 
>>    Integer
>> 
>> Well, inf is supported in floats because it is supported in the native
>> machine double. I suspect that adding inf and -inf (and NaN) to integers
>> would end up being a pretty heavy-weight addition.
> Python 3's int isn't limited to a native machine integer, so it's not
> impossible to extend it to include infinity...

I doubt it would be a serious performance problem if done right. The big question is how it interacts with other types. (Those confusing corner cases already brought up...)

>> On the other hand, my quicky off the cuff implementation of InfDateTime
>> is, in fact, a  universal infinity -- i.e. it compares as greater than
>> any other object, not just a datetime object.

Including float('inf') and float('nan')? That doesn't seem like a selling point...

>> I did that more because it
>> was easy than anything else, but perhaps it could be generally useful to
>> have a Inf and -Inf object, kind of like None.
>> 
>> Or it would just create a huge set of confusing corner cases :-)
> And who knows what it could break!
> 
>> I would much rather see a infinite datetime object that a big discussion
>> about the implications of a generic infinite object -- it is focused,
>> has proven used cases, and wouldn't impact anything beyond datetime.
> 
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/


More information about the Python-ideas mailing list