[Datetime-SIG] Equality of tzinfo objects

Random832 random832 at fastmail.com
Thu Nov 3 15:15:05 EDT 2016


On Thu, Nov 3, 2016, at 14:24, Alexander Belopolsky wrote:
> On Thu, Nov 3, 2016 at 2:09 PM, Paul G <paul at ganssle.io> wrote:
> 
> > I don't understand why it must be the case that something is considered an
> > "inter-zone" comparison whenever `t.tzinfo is not s.tzinfo`. What is the
> > objection to using `t.tzinfo != s.tzinfo` as the criterion? In general
> > these will be equivalent, but using __eq__ allows time zone providers to
> > determine what is considered an "inter-zone" comparison.
> 
> 
> This was probably the case of premature optimization.  I cannot think of
> any valid reason, but datetime comparisons have always compared tzinfos
> using "is" rather than "==" operator.   We can probably still make a
> change, but it should be implemented and thoroughly tested first.  Please
> open a bug report.

I don't think this really goes far enough. Sure, it allows for times in
America/New_York and US/Eastern to be compared, but doesn't allow for
times from America/Indiana/Indianapolis - which should be considered the
same time zone after 2007, and mechanisms should be provided for a
sufficiently sophisticated pytz implementation to determine this - to be
compared.

So if I understand correctly the purpose of comparing the timezones at
all is for ambiguous times, i.e. those near the DST fall-back transition
- and other interzone comparisons are allowed? Wasn't resolving this
supposed to be the purpose of the fold bit - how do ambiguous times
still exist at all?


More information about the Datetime-SIG mailing list