[Python-ideas] datetime: Support infinity
Steven D'Aprano
steve at pearwood.info
Wed Jan 28 01:46:38 CET 2015
On Tue, Jan 27, 2015 at 05:59:13PM -0500, Alexander Belopolsky wrote:
> On Tue, Jan 27, 2015 at 5:47 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>
> > > Adding dates (or datetimes) is not a valid operation today, so I don't
> > > see why we would need to change behaviour there.
> >
> > We're talking about both datetimes and timestamps here. Please follow.
>
>
> I think Antoine meant "timedeltas". Having a date infinity necessitates an
> infinite timedelta to represent a difference between a finite and an
> infinite date.
>
> While we cannot add dates, it is still a valid question what the result of
> subtracting an infinite date from itself should be. If we make it
> timedelta(0) then date.inf is not that different from date.max.
The obvious question is "What does Postgresql do?"
Same for use-cases, which Antoine asked for. The primary use-case is to
improve compatibility with Postgresql while still treating the full
range of dates up to and including date.max as regular dates.
I'm not convinced that numpy is the right library to follow here. Unless
there are cases where you would perform calculations with Not-A-Time, an
exception would probably be better suited.
--
Steve
More information about the Python-ideas
mailing list