Message333504
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. |
|
Date |
User |
Action |
Args |
2019-01-11 20:46:54 | p-ganssle | set | recipients:
+ p-ganssle, lemburg, belopolsky, vstinner |
2019-01-11 20:46:52 | p-ganssle | set | messageid: <1547239612.91.0.545318322695.issue35723@roundup.psfhosted.org> |
2019-01-11 20:46:52 | p-ganssle | link | issue35723 messages |
2019-01-11 20:46:52 | p-ganssle | create | |
|