Skip to content

fix quadratic backtracking in dehumanize unit search#1312

Open
arib06 wants to merge 1 commit into
arrow-py:masterfrom
arib06:dehumanize-search-backtracking
Open

fix quadratic backtracking in dehumanize unit search#1312
arib06 wants to merge 1 commit into
arrow-py:masterfrom
arib06:dehumanize-search-backtracking

Conversation

@arib06

@arib06 arib06 commented Jul 6, 2026

Copy link
Copy Markdown

Pull Request Checklist

  • 🧪 Added tests for changed code.
  • 🛠️ All tests pass when run locally (run tox or make test to find out!).
  • 🧹 All linting checks pass when run locally (run tox -e lint or make lint to find out!).
  • 📚 Updated documentation for changed code.
  • ⏩ Code is up-to-date with the master branch.

Description of Changes

drop the \d prefix alternative in the dehumanize per-unit search regex, since it let re.search re-enter a digit run at every offset so a long run of digits with no trailing unit backtracks the \d+ against the missing literal and turns dehumanize O(n^2) on caller-supplied input ('9'*50000 took ~14s; ^ and \b still anchor every real match, full suite green).

@arib06

arib06 commented Jul 23, 2026

Copy link
Copy Markdown
Author

any update?

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