Repository navigation
split names without escapes at the dots in dns.name.from_text() - #1427
Merged
Merged
Conversation
from_text() read the text one byte at a time, also when the name has no escapes, and made a one-octet bytes object for each byte. If there is no backslash in the text, split it at the dots instead. For a name with escapes, work on the octet values and append them to the label.
Owner
|
A nice speed improvement that is a clean change, thanks! |
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.
dns.name.from_text()read the text one byte at a time and made a 1-bytebytesobject for each byte. When the text has no backslash, it now splits the text at the dots. When the text has escapes, the loop now uses the byte values directly. The output does not change.www1.example.com.I measured no slowdown on names with escapes,
bytearrayinput,@,., names that are not valid, and zone files. I used interleaved rounds and a Mann-Whitney test (Apple M5, 20 rounds on CPython 3.15, 12 rounds on CPython 3.11). On PyPy 3.11, I did 3 paired runs, and all name inputs were faster. Import time did not change (20 rounds). I did not measure other architectures.Checks:
NO_INTERNET=1 pytestpasses on CPython 3.11, CPython 3.15, and PyPy 3.11.ruff check dnspasses.black --checkpasses on the changed files.pyright dnsandty check dnsgive the same results as on main.bytes,bytearray, andmemoryviewtext.bytearrayandmemoryviewinput still work.