Skip to content

Commit 4901bf6

Browse files
authored
Update uuid.rst
1 parent ec4021c commit 4901bf6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doc/library/uuid.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
>>> # make a UUID based on the host ID and current time
453+
>>> # reordered for improved DB locality
454+
>>> uuid.uuid6()
455+
UUID('1f0799c0-98b9-62db-92c6-a0d365b91053')
456+
452457
>>> # get UUIDv7 creation (local) time as a timestamp in milliseconds
453458
>>> u = uuid.uuid7()
454459
>>> u.time # doctest: +SKIP
455460
1743936859822
461+
456462
>>> # get UUIDv7 creation (local) time as a datetime object
457463
>>> import datetime as dt
458464
>>> dt.datetime.fromtimestamp(u.time / 1000) # doctest: +SKIP
459465
datetime.datetime(...)
460466

467+
>>> # make a UUID using three customizable fields
468+
>>> uuid.uuid8(0x12345678, 0x9abcdef0, 0x11223344)
469+
UUID('00001234-5678-8ef0-8000-000011223344')
461470

462471
.. _uuid-cli-example:
463472

0 commit comments

Comments
 (0)