# Copyright 2026 SigmaSRC, Inc. All Rights Reserved.

"""Quick-n-dirty UUID generator.

A UUID is a 128-bit random number.  You're *VERY* unlikely to draw the
same one twice.  We return UUIDs as (long, nonnegative) integers.

UUID format: <80 bits random number> <48 bits timestamp>

The timestamp consists of 32 bits of seconds and 16 bits of subsecond
precision.

"""

import time
import random

__all__ = ["new"]

def new():
    """Return a new UUID (Universally Unique Identifier).

    This is an opaque 128-bit nonnegative number.

    """
    rn = random.randrange(2**80)
    ts = int(time.time() * 2**16) & 0xFFFFFFFFFFFF
    return rn<<48 | ts
