Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postpone timezone regex evaluation until first use - shaves off time from package import #1181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

beda42
Copy link

@beda42 beda42 commented Sep 7, 2023

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 TzRegexCache and 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 of dateparser thus reducing it to less than 20 % of the original import time.

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).
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant