Python Glossary Русский

all Python 3uuidfunction

uuid.uuid1()

generating UUIDs

A version 1 UUID from the current time and the machine's MAC address. Unique without a central counter, but it reveals where and when it was made.

Syntax

uuid.uuid1(node=None, clock_seq=None)

The UUID carries the computer's MAC and the time to 100 ns — both can be read back, so public identifiers use uuid4() instead. It sorts badly: the low bits of the time come first in the string, so string order does not follow creation order — database keys have uuid7(). The value is new every time; only the version, variant and length are predictable.

Examples

import uuid
u = uuid.uuid1()
print(u)  # → ? 7c9e6679-7425-11ef-8f29-a7b78c460531 — время и MAC
print(u.version, u.variant, len(str(u)))  # → 1 specified in RFC 4122 36

See also

Open in the full glossarydocs.python.orgReport an inaccuracy