gh-89083: add links to RFC 9562 sections in UUID docs (#135684)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Undefined behavior sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
JIT / Interpreter (Debug) (push) Waiting to run
JIT / aarch64-pc-windows-msvc/msvc (Release) (push) Blocked by required conditions
JIT / aarch64-pc-windows-msvc/msvc (Debug) (push) Blocked by required conditions
JIT / i686-pc-windows-msvc/msvc (Release) (push) Blocked by required conditions
JIT / i686-pc-windows-msvc/msvc (Debug) (push) Blocked by required conditions
JIT / aarch64-apple-darwin/clang (Release) (push) Blocked by required conditions
JIT / aarch64-unknown-linux-gnu/gcc (Release) (push) Blocked by required conditions
JIT / aarch64-apple-darwin/clang (Debug) (push) Blocked by required conditions
JIT / aarch64-unknown-linux-gnu/gcc (Debug) (push) Blocked by required conditions
JIT / x86_64-pc-windows-msvc/msvc (Release) (push) Blocked by required conditions
JIT / x86_64-pc-windows-msvc/msvc (Debug) (push) Blocked by required conditions
JIT / x86_64-apple-darwin/clang (Release) (push) Blocked by required conditions
JIT / x86_64-unknown-linux-gnu/gcc (Release) (push) Blocked by required conditions
JIT / x86_64-apple-darwin/clang (Debug) (push) Blocked by required conditions
JIT / x86_64-unknown-linux-gnu/gcc (Debug) (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
Tests / Windows MSI (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run

We also sync the docs for UUIDv1 and UUIDv6 concerning the node address and clock sequence.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
Weilin Du 2025-06-20 19:03:41 +08:00 committed by GitHub
parent eec7a8ff22
commit b881e3db1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -193,43 +193,52 @@ The :mod:`uuid` module defines the following functions:
.. function:: uuid1(node=None, clock_seq=None)
Generate a UUID from a host ID, sequence number, and the current time. If *node*
is not given, :func:`getnode` is used to obtain the hardware address. If
*clock_seq* is given, it is used as the sequence number; otherwise a random
14-bit sequence number is chosen.
Generate a UUID from a host ID, sequence number, and the current time
according to :rfc:`RFC 9562, §5.1 <9562#section-5.1>`.
When *node* is not specified, :func:`getnode` is used to obtain the hardware
address as a 48-bit positive integer. When a sequence number *clock_seq* is
not specified, a pseudo-random 14-bit positive integer is generated.
If *node* or *clock_seq* exceed their expected bit count,
only their least significant bits are kept.
.. function:: uuid3(namespace, name)
Generate a UUID based on the MD5 hash of a namespace identifier (which is a
UUID) and a name (which is a :class:`bytes` object or a string
that will be encoded using UTF-8).
that will be encoded using UTF-8)
according to :rfc:`RFC 9562, §5.3 <9562#section-5.3>`.
.. function:: uuid4()
Generate a random UUID.
Generate a random UUID in a cryptographically-secure method
according to :rfc:`RFC 9562, §5.4 <9562#section-5.4>`.
.. function:: uuid5(namespace, name)
Generate a UUID based on the SHA-1 hash of a namespace identifier (which is a
UUID) and a name (which is a :class:`bytes` object or a string
that will be encoded using UTF-8).
that will be encoded using UTF-8)
according to :rfc:`RFC 9562, §5.5 <9562#section-5.5>`.
.. function:: uuid6(node=None, clock_seq=None)
Generate a UUID from a sequence number and the current time according to
:rfc:`9562`.
:rfc:`RFC 9562, §5.6 <9562#section-5.6>`.
This is an alternative to :func:`uuid1` to improve database locality.
When *node* is not specified, :func:`getnode` is used to obtain the hardware
address as a 48-bit positive integer. When a sequence number *clock_seq* is
not specified, a pseudo-random 14-bit positive integer is generated.
If *node* or *clock_seq* exceed their expected bit count, only their least
significant bits are kept.
If *node* or *clock_seq* exceed their expected bit count,
only their least significant bits are kept.
.. versionadded:: 3.14