Paul Ganssle <p.gans...@gmail.com> added the comment:

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.

----------
nosy: +belopolsky, lemburg, vstinner

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35723>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to