Skip to content

aminalaee/uuid-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

142 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Python UUID Utils

Package version PyPI - Downloads Supported Python versions CodSpeed


Fast, drop-in replacement for Python's uuid module, powered by Rust.

Available UUID versions:

  • uuid1 - Version 1 UUIDs using a timestamp and monotonic counter.
  • uuid3 - Version 3 UUIDs based on the MD5 hash of some data.
  • uuid4 - Version 4 UUIDs with random data.
  • uuid5 - Version 5 UUIDs based on the SHA1 hash of some data.
  • uuid6 - Version 6 UUIDs using a timestamp and monotonic counter.
  • uuid7 - Version 7 UUIDs using a Unix timestamp ordered by time.
  • uuid8 - Version 8 UUIDs using user-defined data.

Installation

Using pip:

pip install uuid-utils

or, using conda:

conda install -c conda-forge uuid-utils

Example

>>> import uuid_utils as uuid

>>> # make a random UUID
>>> uuid.uuid4()
UUID('ffe95fcc-b818-4aca-a350-e0a35b9de6ec')

>>> # make a random UUID using a Unix timestamp which is time-ordered.
>>> uuid.uuid7()
UUID('018afa4a-0d21-7e6c-b857-012bc678552b')

>>> # make a UUID using a SHA-1 hash of a namespace UUID and a name
>>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')

>>> # make a UUID using an MD5 hash of a namespace UUID and a name
>>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')

Compatibility with Python UUID

Some frameworks (e.g. Django) require UUID instances from the standard-library uuid module, not a custom subclass. Use uuid_utils.compat for a drop-in replacement that returns stdlib uuid.UUID instances while still outperforming the standard library.

>>> import uuid_utils.compat as uuid

>>> uuid.uuid4()
UUID('ffe95fcc-b818-4aca-a350-e0a35b9de6ec')

Benchmarks

Benchmarks

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ benchdiff โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                                                                                    โ”‚
โ”‚   Benchmark                     Min           Median          Max           ร—      โ”‚
โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”‚
โ”‚   uuid4()                                                                          โ”‚
โ”‚     stdlib_uuid4             1249.762ns     1294.023ns     1325.939ns    22.589x   โ”‚
โ”‚     compat_uuid4             409.614ns      417.891ns      437.917ns     7.295x    โ”‚
โ”‚     uuid_utils_uuid4          55.411ns       57.285ns       58.973ns     1.000x    โ”‚
โ”‚   uuid7()                                                                          โ”‚
โ”‚     stdlib_uuid7             1396.391ns     1451.147ns     1564.087ns    17.400x   โ”‚
โ”‚     compat_uuid7             427.337ns      432.519ns      436.724ns     5.186x    โ”‚
โ”‚     uuid_utils_uuid7          82.539ns       83.397ns      102.663ns     1.000x    โ”‚
โ”‚   UUID from hex                                                                    โ”‚
โ”‚     stdlib_from_hex          423.353ns      431.943ns      621.810ns     5.769x    โ”‚
โ”‚     uuid_utils_from_hex       74.149ns       74.868ns       75.613ns     1.000x    โ”‚
โ”‚   UUID from bytes                                                                  โ”‚
โ”‚     stdlib_from_bytes        370.027ns      373.883ns      383.646ns     3.772x    โ”‚
โ”‚     uuid_utils_from_bytes     97.189ns       99.132ns      102.382ns     1.000x    โ”‚
โ”‚                                                                                    โ”‚
โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚
โ”‚   Python      3.14.2                                                               โ”‚
โ”‚   Platform    macOS-26.3.1                                                         โ”‚
โ”‚   CPU         Apple M3 Pro                                                         โ”‚
โ”‚   Rounds      10 ร— 100,000 calls                                                   โ”‚
โ”‚   Date        2026-05-09 12:38:51                                                  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

How to develop locally

make build
make test

Or:

maturin develop --release

About

Fast, drop-in replacement for Python's uuid module, powered by Rust.

Topics

Resources

License

Stars

Watchers

Forks

Contributors