Repository navigation
Conversation
AdrianAtZyte
approved these changes
Nov 19, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #229 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 1034 1043 +9
Branches 174 176 +2
=========================================
+ Hits 1034 1043 +9 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
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.
For each token,
tokenize()runs the whitespace, identifier, hash and number regular expressions until one matches. This change tests the first character before the regular expressions. ADELIMsuch as>,[or.(when no digit follows) gets its token at once, and the whitespace regular expression runs only on whitespace. Also,unescape_ident()does not runre.sub()on an identifier without a backslash. The output does not change.HTMLTranslator().css_to_xpath(), CPython 3.14divwith 12 classesOn CPython 3.11 and 3.15, the 10 selectors were 10.8% and 12.7% faster. Selectors such as
aanddiv.itemuse the fast path inparse(), so they do not change.On CPython 3.11, a token stream with an escape in each identifier was 3.4% slower. Selectors with escapes were 6-9% faster. On CPython, I measured no other slowdown. I used 20 interleaved rounds and a Mann-Whitney test (Apple M5, CPython 3.11, 3.14 and 3.15). On PyPy 3.11, the escape stream was 0-0.8% slower in 4 runs. The other results were in the noise range, or faster. Import time did not change (30 rounds). I did not measure other architectures.
Checks:
tox -e py,py311,py315,pypy311,typing,pylint,pre-commit,docspasses.test_tokenizershows a.before and after a digit.