Repository navigation
make relative-date regex digit quantifiers possessive - #1335
Merged
serhii73 merged 3 commits intoJun 9, 2026
Merged
Conversation
Closed
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1335 +/- ##
==========================================
- Coverage 97.11% 97.11% -0.01%
==========================================
Files 235 235
Lines 2912 2909 -3
==========================================
- Hits 2828 2825 -3
Misses 84 84 β View full report in Codecov by Harness. π New features to boost your workflow:
|
serhii73
approved these changes
Jun 9, 2026
Collaborator
|
Thanks! |
Merged
3 tasks done
serhii73
added a commit
that referenced
this pull request
Aug 10, 2026
Add CodSpeed benchmarks and a GitHub Actions workflow that runs them, so a performance regression like the one fixed in #1335 is reported on the pull request that introduces it instead of being noticed as a hang. The benchmarks cover the paths #1335 touched: PATTERN.findall()/sub() in freshness_date_parser, the relative-split regex Dictionary builds from the locale's relative-type-regex entries, and dateparser.parse() end to end. Each long-digit-run benchmark is sized so that a reintroduced regression is a ~500x jump that still finishes and reports rather than timing out. The benchmarks live in a dedicated tox environment and are skipped when pytest-codspeed is not installed, leaving the regular test runs unchanged. Closes #1336 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
serhii73
added a commit
that referenced
this pull request
Aug 10, 2026
Add CodSpeed benchmarks and a GitHub Actions workflow that runs them, so a performance regression like the one fixed in #1335 is reported on the pull request that introduces it instead of being noticed as a hang. The benchmarks cover the paths #1335 touched: PATTERN.findall()/sub() in freshness_date_parser, the relative-split regex Dictionary builds from the locale's relative-type-regex entries, and dateparser.parse() end to end. Each long-digit-run benchmark is sized so that a reintroduced regression is a ~500x jump that still finishes and reports rather than timing out. The benchmarks live in a dedicated tox environment and are skipped when pytest-codspeed is not installed, leaving the regular test runs unchanged. Closes #1336 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
AdrianAtZyte
pushed a commit
that referenced
this pull request
Aug 13, 2026
Add CodSpeed benchmarks and a GitHub Actions workflow that runs them, so a performance regression like the one fixed in #1335 is reported on the pull request that introduces it instead of being noticed as a hang. The benchmarks cover the paths #1335 touched: PATTERN.findall()/sub() in freshness_date_parser, the relative-split regex Dictionary builds from the locale's relative-type-regex entries, and dateparser.parse() end to end. Each long-digit-run benchmark is sized so that a reintroduced regression is a ~500x jump that still finishes and reports rather than timing out. The benchmarks live in a dedicated tox environment and are skipped when pytest-codspeed is not installed, leaving the regular test runs unchanged. Closes #1336 Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 task done
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.
The relative-date matchers are built from
\d+[.,]?\d*and run across the whole input:PATTERNinfreshness_date_parserviafindall/sub, and thesplit_relativeregex indictionary.pyviasplit. On a long run of digits the two adjacent digit quantifiers backtrack without ever changing the match, so cost grows superlinearly.Repro:
dateparser.parse('9' * 3200), or any long digit run reaching the relative parser.Cause: the expression is matched at every position; splitting
\d+against\d*over a digit run backtracks quadratically insplit, near-cubically for the freshnessfindall.Fix: make the digit quantifiers possessive (
\d++/\d*+). A digit run can only be followed by[.,]or the literal unit text, so giving digits back can never complete a match.PATTERN.findall('9' * 3200)goes from ~23s to ~0.02s; match results are unchanged and the existing suite passes.