<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 14, 2015 at 3:30 PM, Tim Peters <span dir="ltr"><<a href="mailto:tim.peters@gmail.com" target="_blank">tim.peters@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> make it much cheaper to maintain global invariants like a sort order<br>
> according to the UTC value<br>
<br>
</span>It would be nice to have!  .utcoffset() is an expensive operation<br>
as-is, and being able to rely on tm_gmtoff would make that dirt-cheap<br>
instead.</blockquote></div><br>If it  is just a question of optimization, datetime objects can be extended to cache utcoffset.  Note that PyPy have recently added caching of the hash values in datetime objects.  I merged their changes in our datetime.py, but it did not look like C implementation would benefit from it as much as pure python did.  I expect something similar from caching utcoffset: a measurable improvement for tzinfos implemented in Python and a wash for those implemented in C.  (A more promising optimization approach is to define a C API for tzinfo interface.)</div></div>