On Tue, Sep 8, 2015 at 2:02 PM, Tim Peters <[email protected]> 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 other.utcoffset(). 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.
_______________________________________________ Datetime-SIG mailing list [email protected] https://mail.python.org/mailman/listinfo/datetime-sig The PSF Code of Conduct applies to this mailing list: https://www.python.org/psf/codeofconduct/
