gh-150226: Speed up uuid.UUID string parsing#150227
Closed
esadomer wants to merge 1 commit into
Closed
Conversation
bdf214f to
95fbb8b
Compare
95fbb8b to
b457838
Compare
Member
|
See issue for the rationale of closing this. |
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.
gh-150226
Summary
This speeds up
uuid.UUIDconstruction from the documented string forms by handling the documentedurn:uuid:prefix directly withstr.removeprefix()before stripping braces and hyphens.The previous broader normalization path is still used as a fallback whenever the direct normalization does not produce 32 hex characters, preserving legacy accepted inputs such as
urn:<hex>.Benchmark
Same-process benchmark on a local Windows CPython debug build, comparing
origin/main:Lib/uuid.pywith this patch while blocking_uuidto isolate the pure-Python constructor path:Absolute timings are from a debug build; the benchmark compares old and new code in the same process.
Tests
PCbuild\build.bat -d -p x64PCbuild\amd64\python_d.exe -m test test_uuid -vI also attempted a local Windows Release build, but MSVC failed with an internal compiler error while compiling/linking
externals\zlib-ng-2.2.4\arch\x86\chunkset_avx2.c, unrelated to thisuuidchange.