From 8680fa4451c62624a70944d98b2d8ba1ae788419 Mon Sep 17 00:00:00 2001 From: LamentXU <108666168+LamentXU123@users.noreply.github.com> Date: Thu, 19 Jun 2025 00:42:20 +0800 Subject: [PATCH 1/5] Update uuid.rst --- Doc/library/uuid.rst | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Doc/library/uuid.rst b/Doc/library/uuid.rst index 92d58024e84d4e..109e70c7665dce 100644 --- a/Doc/library/uuid.rst +++ b/Doc/library/uuid.rst @@ -193,9 +193,12 @@ 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 + Generate a UUID from a host ID, sequence number, and the current time + according to :rfc:`RFC 9562, §5.1 <9562#section-5.1>`. + + 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. @@ -203,25 +206,29 @@ The :mod:`uuid` module defines the following functions: 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 From b911f1e78dc7a3ad7b016655cee2a9797761e212 Mon Sep 17 00:00:00 2001 From: LamentXU <108666168+LamentXU123@users.noreply.github.com> Date: Thu, 19 Jun 2025 00:49:20 +0800 Subject: [PATCH 2/5] Update uuid.rst --- Doc/library/uuid.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/uuid.rst b/Doc/library/uuid.rst index 109e70c7665dce..9ec3615b8d0b64 100644 --- a/Doc/library/uuid.rst +++ b/Doc/library/uuid.rst @@ -193,11 +193,11 @@ 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 + Generate a UUID from a host ID, sequence number, and the current time according to :rfc:`RFC 9562, §5.1 <9562#section-5.1>`. 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. From c69a050b885928dd5cb8afb578a9433a8b9769d0 Mon Sep 17 00:00:00 2001 From: LamentXU <108666168+LamentXU123@users.noreply.github.com> Date: Thu, 19 Jun 2025 20:47:19 +0800 Subject: [PATCH 3/5] Update Doc/library/uuid.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Doc/library/uuid.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/uuid.rst b/Doc/library/uuid.rst index 9ec3615b8d0b64..6e858afa5d0ab7 100644 --- a/Doc/library/uuid.rst +++ b/Doc/library/uuid.rst @@ -196,9 +196,9 @@ The :mod:`uuid` module defines the following functions: Generate a UUID from a host ID, sequence number, and the current time according to :rfc:`RFC 9562, §5.1 <9562#section-5.1>`. - 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 + 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. 14-bit sequence number is chosen. From b55a920f95333206e93f5e252eca4f06037a0667 Mon Sep 17 00:00:00 2001 From: LamentXU <108666168+LamentXU123@users.noreply.github.com> Date: Fri, 20 Jun 2025 08:25:13 +0800 Subject: [PATCH 4/5] Update uuid.rst --- Doc/library/uuid.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/library/uuid.rst b/Doc/library/uuid.rst index 6e858afa5d0ab7..a34c7723caa20e 100644 --- a/Doc/library/uuid.rst +++ b/Doc/library/uuid.rst @@ -199,7 +199,6 @@ The :mod:`uuid` module defines the following functions: 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. - 14-bit sequence number is chosen. .. function:: uuid3(namespace, name) From f1290535de757a2bd3a88093792da9ae3b08cf85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Fri, 20 Jun 2025 12:58:19 +0200 Subject: [PATCH 5/5] sync uuid1 & uuid6 docs --- Doc/library/uuid.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/library/uuid.rst b/Doc/library/uuid.rst index a34c7723caa20e..6698e6d3f43c43 100644 --- a/Doc/library/uuid.rst +++ b/Doc/library/uuid.rst @@ -200,6 +200,9 @@ The :mod:`uuid` module defines the following functions: 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) @@ -234,8 +237,8 @@ The :mod:`uuid` module defines the following functions: 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