improve efficiency by using all_timezones_set instead of all_timezones
Bug #314780 reported by
Daniel Stutzbach
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pytz |
Fix Released
|
Medium
|
Stuart Bishop |
Bug Description
In a couple places during initialization, pytz/__init__.py uses the form "in all_timezones", which is an expensive (O(n)) search through the list of all timezones. Wouldn't it be much more efficient to use "in all_timezones_set"?
For that matter, why not eliminate the confusion and simply replace:
all_
with:
all_timezones = set(all_timezones)
(and likewise for common_timezones)
Related branches
Changed in pytz: | |
status: | Triaged → Fix Committed |
Changed in pytz: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
We should use the set where possible instead of the list.
The lists need to stay with their existing names for backwards compatibility.