2019-07-08 14:53:15 |
kmichel |
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_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones)
This line was added for the case insensitive lookup in this commit:
https://git.launchpad.net/pytz/commit/?id=78d76e59e52761b30cdf413be23d7d5e57ed416c
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 490ms and numpy needs 1200ms). |
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_lower_to_standard = dict((tz.lower(), tz) for tz in all_timezones)
This line was added for the case insensitive lookup in this commit:
https://git.launchpad.net/pytz/commit/?id=78d76e59e52761b30cdf413be23d7d5e57ed416c
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). |
|