Yeah, looks like it had support in principle but just went quiet. I'd be ok with just having it as a third-party library, but the real value comes when your data layer supports it directly - psycopg2, ORMs, etc. That's far more likely to happen if it's built-in. Thanks for responding! Cheers, Alex On Wed, Jun 17, 2020 at 11:48 AM Christopher Barker <pythonchb@gmail.com> wrote:
I think I recall that discussion -- but don't recall how it ended. Did it just peter out?
Anyway, +1 form me -- I've actually got my own implementation as well. So it certainly has a use case, and it's really better to have one version in the stdlib.
I haven't had a chance to review your implementation, but if it looks like you're getting support, I'll be sure to do so.
-CHB
On Tue, Jun 16, 2020 at 5:45 AM Alexander Hill <alex@hill.net.au> wrote:
Hi all,
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!
Usage examples:
from temporal_infinities import * from datetime import * DATETIME_POS_INF - datetime(2020, 6, 15) TIMEDELTA_POS_INF DATETIME_NEG_INF < date(2020, 6, 15) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: '<' not supported between instances of 'DatetimeInfinity' and 'datetime.date' DATE_NEG_INF < date(2020, 6, 15) True date(2020, 6, 15) + TIMEDELTA_POS_INF DATE_POS_INF TIMEDELTA_NEG_INF == TIMEDELTA_NEG_INF True
My implementation is at https://github.com/AlexHillAlexHill/temporal-infinities <https://github.com/AlexHill/temporal-infinities> and is designed to be as consistent with the behaviour of floating-point infinities as possible. The expected behaviour of the various types is captured in test_matrix.csv, which is used to produce test cases. Blank cells indicate that a TypeError should be raised. It's tested back to Python 3.4.
Previous discussion: https://mail.python.org/pipermail/python-ideas/2015-January/031414.html
Thanks for your time!
Alex _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/S4H553... Code of Conduct: http://python.org/psf/codeofconduct/
-- Christopher Barker, PhD
Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython