LazyList all_timezones is always evaluated at pytz import
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pytz |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Despite the effort to use a LazyList for all_timezones,
the list of timezones is always evaluated as soon as pytz is imported.
This is caused by this line in the distributed file pytz/__init__.py
(this is added by gen_tzinfo.py and not directly visible in the repo):
_all_timezones_
This line was added for the case insensitive lookup in this commit:
https:/
This addition cause a startup delay of about 540ms on my computer.
Without the line:
import time: self [us] | cumulative | imported package
[...]
import time: 34059 | 41445 | pytz
With the line (using python -X importtime):
import time: self [us] | cumulative | imported package
[...]
import time: 577866 | 586989 | pytz
(As a reference point, boto3 needs 240ms and numpy needs 1200ms).
description: | updated |
Changed in pytz: | |
status: | New → Triaged |
Changed in pytz: | |
status: | Fix Committed → Fix Released |
This can be deferred until timezone lookup time