1. Dates beyond year 9999 aren't a prerequisite for infinite types - I see that as a separate issue. The fact that we can't represent dates between 9999 and infinity doesn't make infinity less useful :)
2 & 3. Yeah, string representation is something that needs to be decided on - that's a big potential bikeshed. My preference at this stage would be for these to be called e.g. date.inf_future and date.inf_past, and the string representation to be the same. timedelta could simply have timedelta.infinity, and since it supports __neg__, -timedelta.infinity would work just fine. I'd like to hear other views though. 4. In my implementation, `datetime.now() - DATETIME_NEG_INF == TIMEDELTA_POS_INF`. I haven't implemented the division dunder methods yet, but by analogy to float, I would say that `TIMEDELTA_POS_INF / timedelta(days=1) == float("inf")` and `TIMEDELTA_POS_INF // timedelta(days=1)` raises TypeError (the latter returns nan in the case of float). Thanks, Alex On Wed, Jun 17, 2020 at 2:57 PM Serhiy Storchaka <storch...@gmail.com> wrote: > 16.06.20 13:54, Alexander Hill пише: > > I’d like to propose support for infinite dates, datetimes and > > timedeltas. They're very useful when you need to model ranges with one > > or both ends unbounded (e.g. “forever starting from June 15th 2020”). > > > > Without first-class infinite values, you can use None, or you can use > > the `min` and `max` attributes of Python’s datetime types, or some other > > arbitrary large values. Using None means you need to implement a path > > for None, and a path for everything else, and your various infinite > > values are indistinguishable. Using max/min means comparisons just work, > > but calculations need special treatment and you’re fundamentally > > misrepresenting your meaning. > > > > Temporal infinities give the best of both worlds: infinite values that > > interoperate seamlessly with the built-in types and behave sensibly and > > predictably. They’re also supported by Postgres! > > First we need to solve some problems. > > 1. Parsing dates with more than 4-digit year. Note that many external > implementations do not support such data, so we need a way to restrict > the data range when convert them to string representation. > > 2. String representations and parsing for negative data. > > 3. String representations and parsing for infinity data (positive and > negative). > > 4. If datetime.min will be the negative infinity, then what will be the > result of `datetime.now() - datetime.min`? Or `(datetime.now() - > datetime.min) // timedelta(days=1)`? > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/2GZ5BNIGV43224QWTUCYO57MB7E7BDTB/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/JUQRTKPJBUCSQTJEYTCRZYONX25OMHRR/ Code of Conduct: http://python.org/psf/codeofconduct/