Python Glossary Русский

all Python 3uuidfunction

uuid.uuid3()

generating UUIDs

A version 3 UUID — deterministic: MD5 of a namespace and a name. The same name always gives the same UUID.

Syntax

uuid.uuid3(namespace, name)

It gives a stable identifier for an already unique name (a domain, a URL) without storing a lookup table. The name is compared byte by byte: 'python.org' and 'Python.org' give different UUIDs, so normalize the name first. New code should prefer uuid5() on SHA-1; uuid3() is for matching values already issued by another system.

Examples

import uuid
u = uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
print(u)  # → 6fa459ea-ee8a-3ca4-894e-db77e160355e
print(u == uuid.uuid3(uuid.NAMESPACE_DNS, 'Python.org'))  # → False

See also

Open in the full glossarydocs.python.orgReport an inaccuracy