Skip to content

Commit

Permalink
Avoid repeated loop over timezones (#1238)
Browse files Browse the repository at this point in the history
By removing repeated iteration over timezones, the import time is reduced by 5-10%.
  • Loading branch information
nijel authored Oct 2, 2024
1 parent f114394 commit 6a7c91c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions dateparser/timezone_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ def get_offset(tz_obj, regex, repl="", replw=""):
search_regex_parts.append(tz_obj[0])
yield get_offset(tz_obj, regex)

# alternate patterns
for replace, replacewith in tz_info.get("replace", []):
for tz_obj in tz_info["timezones"]:
# alternate patterns
for replace, replacewith in tz_info.get("replace", []):
search_regex_parts.append(re.sub(replace, replacewith, tz_obj[0]))
yield get_offset(tz_obj, regex, repl=replace, replw=replacewith)

Expand Down

0 comments on commit 6a7c91c

Please sign in to comment.