[Datetime-SIG] PEP 495: What's left to resolve

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Sep 8 20:19:08 CEST 2015

On Tue, Sep 8, 2015 at 2:02 PM, Tim Peters <tim.peters at gmail.com> wrote:

> > Are you just saying that a slowdown in interzone comparison is a
> > welcome feature to discourage bad programming practices?   Sorry,
> > I have a few ideas on how to optimize Solution 3  __eq__ even
> > without special-casing fixed-offset tzinfos. :-)
> Premature optimization is the root of all evil.

Agree 100%.

>   You're proposing to add even more complication to the code

No, I actually think the code can be simpler (and without an infinite
recursion.)  In any case, it won't matter for the CPython users what we
will ship in datetime.py, so I will write something that make the intent
very clear.  The type of optimization that I had in mind was that once you
discover that self is in the fold/gap, you can return False without calling

The question is what is easier to understand: (a) t1 and t2 are equal if
and only if t1 - t1.replace(fold=f1).utcoffset() ==  t2 -
t2.replace(fold=f2).utcoffset() for all four possible pairs (f1, f2); or
(b) t1 and t2 are equal if and only if they are unambiguous and valid in
their respective zones and convert to the same UTC instant.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150908/ecaf74fc/attachment.html>

More information about the Datetime-SIG mailing list