-
Notifications
You must be signed in to change notification settings - Fork 523
Description
A huge amount of the time zone functions are called multiple times with identical inputs and expecting identical outputs, and the whole concept of a tzinfo is that it should be more-or-less a singleton, so there's a huge potential for memoization that is not realized.
Ideally, we'll stub out an equivalent of functools.lrucache so that it's backward compatible. I will update this list later, but here's a starter of things that need to be memoized:
-
gettz -
tzfile(utcoffset,dst,tzname) -
tzical(already done to some extent, but we should convert this over to the same way everything else is)
Likely all non-static offsets will need utcoffset, dst and tzname memoized.
The big concern with doing this is that it will likely increase memory consumption in downstream applications, some of which may be operating in memory-constrained environments. I'm thinking the best way to address this is to query an environment variable at import-time that sets the length of the caches to something other than default.