Skip to content

Commit 132b866

Browse files
miss-islingtonLamentXU123picnixz
authored
[3.14] gh-137847: Add examples for UUIDv6-8 (GH-137848) (#137901)
Co-authored-by: Weilin Du <108666168+LamentXU123@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
1 parent cf5c170 commit 132b866

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Doc/library/uuid.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ Here are some examples of typical usage of the :mod:`uuid` module::
411411
>>> import uuid
412412

413413
>>> # make a UUID based on the host ID and current time
414-
>>> uuid.uuid1()
414+
>>> uuid.uuid1() # doctest: +SKIP
415415
UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
416416

417417
>>> # make a UUID using an MD5 hash of a namespace UUID and a name
@@ -449,15 +449,24 @@ Here are some examples of typical usage of the :mod:`uuid` module::
449449
>>> uuid.MAX
450450
UUID('ffffffff-ffff-ffff-ffff-ffffffffffff')
451451

452+
>>> # same as UUIDv1 but with fields reordered to improve DB locality
453+
>>> uuid.uuid6() # doctest: +SKIP
454+
UUID('1f0799c0-98b9-62db-92c6-a0d365b91053')
455+
452456
>>> # get UUIDv7 creation (local) time as a timestamp in milliseconds
453457
>>> u = uuid.uuid7()
454458
>>> u.time # doctest: +SKIP
455459
1743936859822
460+
456461
>>> # get UUIDv7 creation (local) time as a datetime object
457462
>>> import datetime as dt
458463
>>> dt.datetime.fromtimestamp(u.time / 1000) # doctest: +SKIP
459464
datetime.datetime(...)
460465

466+
>>> # make a UUID with custom blocks
467+
>>> uuid.uuid8(0x12345678, 0x9abcdef0, 0x11223344)
468+
UUID('00001234-5678-8ef0-8000-000011223344')
469+
461470

462471
.. _uuid-cli-example:
463472

0 commit comments

Comments
 (0)