[Datetime-SIG] Are there any "correct" implementations of tzinfo?

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Sep 14 15:44:25 EDT 2015


On Mon, Sep 14, 2015 at 3:30 PM, Tim Peters <tim.peters at gmail.com> wrote:

> > make it much cheaper to maintain global invariants like a sort order
> > according to the UTC value
>
> It would be nice to have!  .utcoffset() is an expensive operation
> as-is, and being able to rely on tm_gmtoff would make that dirt-cheap
> instead.


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.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150914/330ba3d6/attachment.html>


More information about the Python-list mailing list