GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-156185: Ignore all ASCII whitespace in re \p{} property names by Georgefifth · Pull Request #156304 · python/cpython Conversation
|
| # hyphens and underscores are not significant, and an initial "is" prefix | ||
| # is ignored (UAX #44 5.9, "Matching Rules", UAX44-LM3; | ||
| # Unicode property and value names are matched loosely: case, whitespace | ||
| # and hyphens and underscores are not significant, and an initial "is" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Double "and".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # prefix is ignored (UAX #44 5.9, "Matching Rules", UAX44-LM3; | ||
| # https://www.unicode.org/reports/tr44/). | ||
| name = name.lower().replace("_", "").replace("-", "").replace(" ", "") | ||
| name = "".join(ch for ch in name.lower() if ch not in " \t\n\r\f\v_-") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This code is significantly slower than a sequence of replaces. The fastest method is to use translate() with predefined table created by str.maketrans().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Also, no NEWS entry is needed. This is a fix of an unreleased feature.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
8b94a7c to
0bfce66
Compare
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
All three addressed in 0bfce66:
name.lower().translate(_NON_SIGNIFICANT) with the table built once via str.maketrans("", "", " \t\n\r\f\v_-") at module level. Measured on a 33-char name: ~1.4x faster than the generator expression.test_re passes on a locally built interpreter (169 tests, 3 skipped, all pre-existing skips).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.