This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author p-ganssle
Recipients belopolsky, lemburg, p-ganssle, vstinner
Date 2019-01-11.20:46:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547239612.91.0.545318322695.issue35723@roundup.psfhosted.org>
In-reply-to
Content
One other thing I might mention here is that I did explore the idea of storing this cache on the tzinfo implementation itself, but it is problematic for a number of reasons:

1. It would either need to use some sort of expiring cache (lru, ttl) or require a great deal of memory, greatly reducing the utility - the proposed implementation requires no additional memory.
2. Because the implementation of datetime.__hash__ invokes utcoffset(), it is impossible to implement utcoffset in terms of a dictionary of tz-aware datetimes. This means that you need to construct a new, naive datetime, which is a fairly slow operation and really puts a damper in the utility of the cache.

If I were designing this from scratch, I would probably implement it differently, but I think this approach is pretty close to ideal given the constraints of backwards compatibility.
History
Date User Action Args
2019-01-11 20:46:54p-gansslesetrecipients: + p-ganssle, lemburg, belopolsky, vstinner
2019-01-11 20:46:52p-gansslesetmessageid: <1547239612.91.0.545318322695.issue35723@roundup.psfhosted.org>
2019-01-11 20:46:52p-gansslelinkissue35723 messages
2019-01-11 20:46:52p-gansslecreate