uuid.uuid4() vs uuid.uuid1()
uuid.uuid4() and uuid.uuid1() are both Python UUID Module APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. uuid.uuid4(): Generates a random UUID (version 4). Most commonly used UUID type. Its syntax is uuid.uuid4(), and it returns uUID object uuid.uuid1(): Generates a time-based UUID (version 1) using host MAC address and timestamp. Its syntax is uuid.uuid1(node=None, clock_seq=None), and it returns uUID object Example of uuid.uuid4(): import uuid
uuid.uuid4() # UUID("550e8400-e29b-41d4-a716-446655440000"). Example of uuid.uuid1(): uuid.uuid1() # UUID with timestamp and MAC. Read the full references for uuid.uuid4() and uuid.uuid1() to see parameters, edge cases, and example code side by side. Other UUID Module APIs worth comparing: uuid.uuid3(), uuid.uuid5(), uuid.UUID. Both belong to the UUID Module category in the Python Reference documentation. Try both in the Python playground to see the behavioral difference live.