improve efficiency by using all_timezones_set instead of all_timezones

Bug #314780 reported by Daniel Stutzbach
2
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_timezones_set = set(all_timezones)
with:
    all_timezones = set(all_timezones)

(and likewise for common_timezones)

Related branches

Revision history for this message
Stuart Bishop (stub) wrote :

We should use the set where possible instead of the list.

The lists need to stay with their existing names for backwards compatibility.

Changed in pytz:
assignee: nobody → stub
importance: Undecided → Medium
status: New → Triaged
Stuart Bishop (stub)
Changed in pytz:
status: Triaged → Fix Committed
Stuart Bishop (stub)
Changed in pytz:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.