Repository navigation
Conversation
Documentation build overview
5 files changed ·
|
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.
Follow-up to #139123; refs #139122.
Add a C implementation of
uuid.uuid6(), keeping the pure Python implementation as a fallback. Both implementations now use OS entropy for default clock sequences. The C implementation caches the default node ID per module, with a separate mutex for initialization and an atomic cache lookup. Critical sections around shared timestamp and entropy state stay short, and Python callbacks run outside the timestamp update.The tests compare the Python and C implementations byte for byte with matching time and entropy streams, including repeated and backward timestamps, argument masking, entropy buffer refills, and interleaved UUID4/6/7 calls. Additional tests cover callback failures, node cache initialization and reset, reentrancy, and concurrent calls.
Validation:
test_uuidsuite passed on debug GIL and free-threaded builds, including-R 3:3reference leak checks.-O3GIL and free-threaded builds; the expanded equivalence tests also passed on both.The benchmark below generates UUIDs for five seconds per implementation, retains them in per-thread sets, and checks for duplicates across all threads afterward. Each implementation runs in a fresh process. Sample results on non-debug
-O3builds (no PGO):These are individual runs and include set insertion costs. No duplicates were detected in the C runs. The eight-thread pure Python run produced 13 duplicates, exposing an existing race in its timestamp update; fixing that fallback race remains separate work. The new deterministic equivalence tests cover sequential behavior, while the concurrency tests exercise the C implementation.
Benchmark script (save as bench_uuid6.py)