postpone timezone regex evaluation until first use - shaves off time from package import#1181
Closed
beda42 wants to merge 1 commit intoscrapinghub:masterfrom
Closed
postpone timezone regex evaluation until first use - shaves off time from package import#1181beda42 wants to merge 1 commit intoscrapinghub:masterfrom
beda42 wants to merge 1 commit intoscrapinghub:masterfrom
Conversation
…from package import
nijel
added a commit
to nijel/weblate
that referenced
this pull request
Oct 2, 2024
It can be expensive to import due to building thousands of regexps at import time (see scrapinghub/dateparser#1181).
5 tasks
nijel
added a commit
to WeblateOrg/weblate
that referenced
this pull request
Oct 2, 2024
It can be expensive to import due to building thousands of regexps at import time (see scrapinghub/dateparser#1181).
Contributor
|
is this library still actively maintained? i ran into this issue and would like to fix this. my idea is instead to cache the regexes so that overall time gets faster. this solution will still incur regex parsing time, although it does speed up parsing. but i only want to do a PR if it actually has a shot at making it in. |
Contributor
|
We are reviewing PRs, and may even have a release “soon” (see the most recent PRs). |
Contributor
amazing! would you accept my idea? is there somewhere to discuss with maintainers this approach before i start to make iterations faster? |
Contributor
|
You can either start a draft PR with little code and start the discussion there, or discuss it here. |
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Jan 30, 2025
this is different from pr scrapinghub#1181. that pr only makes import faster but still incurs cost on the first usage. this one leverages an optional cache. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Jan 30, 2025
this is different from pr scrapinghub#1181. that pr only makes import faster but still incurs cost on the first usage. this one leverages an optional cache. closes scrapinghub#533
Contributor
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Jan 31, 2025
this is different from pr scrapinghub#1181. that pr only makes import faster but still incurs cost on the first usage. this one leverages an optional cache. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Feb 5, 2025
this is different from pr scrapinghub#1181. it builds a cache at install time which can be distributed. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Feb 5, 2025
this is different from pr scrapinghub#1181. it builds a cache at install time which can be distributed. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Feb 5, 2025
this is different from pr scrapinghub#1181. it builds a cache at install time which can be distributed. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Feb 5, 2025
this is different from pr scrapinghub#1181. it builds a cache at install time which can be distributed. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Feb 10, 2025
this is different from pr scrapinghub#1181. it builds a cache at install time which can be distributed. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Feb 10, 2025
this is different from pr scrapinghub#1181. it builds a cache at install time which can be distributed. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Feb 10, 2025
this is different from pr scrapinghub#1181. it builds a cache at install time which can be distributed. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Feb 10, 2025
this is different from pr scrapinghub#1181. it builds a cache at install time which can be distributed. closes scrapinghub#533
tobymao
added a commit
to tobymao/dateparser
that referenced
this pull request
Feb 13, 2025
this is different from pr scrapinghub#1181. it builds a cache at install time which can be distributed. closes scrapinghub#533
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This MR is related to issue #533 which is caused mainly by a time intensive parsing of regular expressions for timezone matching. This MR introduces a global object
TzRegexCacheand moves preparation of the regexps into it. The regexps are no longer parsed on startup, but during first use instead. On my machine it shaves off about 200 ms from the import time ofdateparserthus reducing it to less than 20 % of the original import time.