[Python-ideas] datetime: Support infinity

Chris Barker chris.barker at noaa.gov
Thu Jan 29 08:04:10 CET 2015

On Wed, Jan 28, 2015 at 6:55 PM, Yawar Amin <yawar.amin at gmail.com> wrote:

> Cool, the comparison operator logic looks very similar to mine:
> https://groups.google.com/d/msg/python-ideas/G3jeWoa6h14/ELpDLFu28QcJ
Did you get it to work both ways? i.e.

datetime.neg_inf < datetime.now()


datetime.now() > datetime.neg_inf

I had trouble with that, because the regular datetime doesn't know how to
compare itself to a neg_inf object.

> I believe the ideal design is the following type hierarchy:
>     datetime_base
>       datetime_neg_inf
>       datetime_pos_inf
>       datetime
> But in the interests of pragmatism, I think this one can be made to
> work:
>     datetime
>       datetime_neg_inf
>       datetime_pos_inf

yup -- should work.

and you could add class methods to the datetime object, so you could do:


> The
advantage to this is that we don't have to switch everything over to
> using a new derived type--just use the normal datetime for the majority
> of cases where we don't need inifinity dates.

And it could be a third part package, too. -- particularly good for
backward compatibility.



Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150128/7e6ed455/attachment-0001.html>

More information about the Python-ideas mailing list