
Thank you very much, that there are some developers who support the idea of infinite in the datetime module.
Next idea: If Python would support infinite in the core, implementing infinite in datetime might be much easier.
What do you think?

On Mon, Feb 02, 2015 at 09:17:36AM +0100, Thomas Güttler wrote:
Thank you very much, that there are some developers who support the idea of infinite in the datetime module.
Next idea: If Python would support infinite in the core, implementing infinite in datetime might be much easier.
I don't understand what that means. What does it mean for Python to support infinite in the core?
Infinite what? Infinite string? Infinite list? What would this infinite do, what methods would it have?
Python already supports float infinities and Decimal infinities. Does that help you?

Am 02.02.2015 um 11:29 schrieb Steven D'Aprano:
On Mon, Feb 02, 2015 at 09:17:36AM +0100, Thomas Güttler wrote:
Thank you very much, that there are some developers who support the idea of infinite in the datetime module.
Next idea: If Python would support infinite in the core, implementing infinite in datetime might be much easier.
I don't understand what that means. What does it mean for Python to support infinite in the core?
Infinite what?
Integer
A infinite timedelta could be created like this:
datetime.timedelta(days=infinite)
Thomas Güttler

On Mon, Feb 2, 2015 at 7:27 AM, Thomas Güttler <guettliml@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.
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. 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 :-)
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.
-Chris

On 2015-02-02 16:45, Chris Barker wrote:
On Mon, Feb 2, 2015 at 7:27 AM, Thomas Güttler <guettliml@thomas-guettler.de mailto:guettliml@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...
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. 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.

On Feb 2, 2015, at 10:03, MRAB python@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@thomas-guettler.de mailto:guettliml@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@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

On Mon Feb 02 2015 at 4:52:49 PM Chris Barker chris.barker@noaa.gov wrote:
On Mon, Feb 2, 2015 at 7:27 AM, Thomas Güttler < guettliml@thomas-guettler.de> wrote:
Infinite what?
Integer
Well, inf is supported in floats because it is supported in the native machine double.
There's also the appeal to mathematics: integers and infinities are mutually exclusive.
By contrast, floats aren't numbers (by most definitions) to begin with, so there's no axiomatic basis to worry about breaking.
Ed Kellett

On Feb 2, 2015, at 10:22, Ed Kellett edk141@gmail.com wrote:
On Mon Feb 02 2015 at 4:52:49 PM Chris Barker chris.barker@noaa.gov wrote:
On Mon, Feb 2, 2015 at 7:27 AM, Thomas Güttler guettliml@thomas-guettler.de wrote:
Infinite what?
Integer
Well, inf is supported in floats because it is supported in the native machine double.
There's also the appeal to mathematics: integers and infinities are mutually exclusive.
An affinely-extended integer set is just as easy to define as an affinely-extended real set, and it preserves the laws of integer arithmetic with the obvious extensions to undefined results (e.g., a+(b+c) == (a+b)+c or both are undefined). In particular, undefined results can be safely modeled with either a quiet nan or with exceptions.
(Also, Python integers don't actually quite model the integers, because for large enough values you get a memory error.)
By contrast, floats aren't numbers (by most definitions) to begin with, so there's no axiomatic basis to worry about breaking.
I suppose it depends how you define "number". It's true that they don't model the laws of arithmetic properly, but they do have a well-defined model (well, each implementation has a different one, but most people only care about the IEEE double/binary64 implementation) that's complete in analogs of the same operations as the reals, even if those analogs aren't actually the same operations.
But, more importantly, the floats with inf and -inf model the affinely extended real numbers the same way the floats without infinities model the reals, so there is definitely an axiomatic basis to the design, not just some haphazard choice Intel made for no good reason.

On Mon, Feb 2, 2015, at 10:27, Thomas Güttler wrote:
Infinite what?
Integer
A infinite timedelta could be created like this:
datetime.timedelta(days=infinite)
Thomas Güttler
You'd still have to decide how to represent it, since timedelta doesn't internally use PyLongObject. (I've asked why these types don't support the unbounded range of integers before, and was told "YAGNI".)
participants (7)
-
Andrew Barnert
-
Chris Barker
-
Ed Kellett
-
MRAB
-
random832@fastmail.us
-
Steven D'Aprano
-
Thomas Güttler