Skip to main content

Drop-in replacement for Python UUID in Rust

Project description

Python UUID Utils

Package version Supported Python versions


Python UUID implementation using Rust's UUID library. This will make uuid4 function around 10x faster.

This package can be a drop-in replacement to the standard library UUID which implements existing UUID versions like v4 in Rust and also adds draft UUID versions like v6.

Avaialble 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.

Please note that UUID versions 6, 7 and 8 are still in draft RFC.

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

In some cases, for example if you are using Django, you might need UUID instances to be returned from the standrad-library uuid, not a custom UUID class. In that case you can use the uuid_utils.compat which comes with a performance penalty in comparison with the uuid_utils default behaviour, but is still faster than the standard-library.

>>> import uuid_utils.compat as uuid

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

Benchmarks

Benchmark Min Max Mean Min (+) Max (+) Mean (+)
UUID v1 0.058 0.059 0.058 0.005 (12.0x) 0.005 (11.9x) 0.005 (12.0x)
UUID v3 0.063 0.064 0.063 0.008 (7.9x) 0.008 (8.1x) 0.008 (8.0x)
UUID v4 0.041 0.041 0.041 0.004 (11.1x) 0.004 (10.8x) 0.004 (10.9x)
UUID v5 0.064 0.066 0.065 0.008 (8.1x) 0.008 (8.1x) 0.008 (8.1x)
UUID from hex 0.024 0.025 0.024 0.004 (6.7x) 0.004 (6.6x) 0.004 (6.6x)
UUID from bytes 0.024 0.025 0.024 0.004 (6.7x) 0.004 (6.6x) 0.004 (6.7x)
UUID from int 0.024 0.025 0.024 0.004 (6.6x) 0.004 (6.7x) 0.004 (6.6x)
UUID from fields 0.028 0.028 0.028 0.009 (3.1x) 0.009 (3.1x) 0.009 (3.1x)

How to develop locally

$ make build
$ make test

Or:

$ RUSTFLAGS="--cfg uuid_unstable" maturin develop --release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uuid_utils-0.9.0.tar.gz (18.2 kB view hashes)

Uploaded Source

Built Distributions

uuid_utils-0.9.0-pp39-pypy39_pp73-win_amd64.whl (172.4 kB view hashes)

Uploaded PyPy Windows x86-64

uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (313.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (347.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (318.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (323.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

uuid_utils-0.9.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl (324.5 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

uuid_utils-0.9.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl (273.6 kB view hashes)

Uploaded PyPy macOS 10.12+ x86-64

uuid_utils-0.9.0-pp39-pypy39_pp73-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (539.1 kB view hashes)

Uploaded PyPy macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

uuid_utils-0.9.0-pp38-pypy38_pp73-win_amd64.whl (172.9 kB view hashes)

Uploaded PyPy Windows x86-64

uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (313.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (347.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (318.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (323.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

uuid_utils-0.9.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl (324.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

uuid_utils-0.9.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl (273.8 kB view hashes)

Uploaded PyPy macOS 10.12+ x86-64

uuid_utils-0.9.0-pp38-pypy38_pp73-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (539.5 kB view hashes)

Uploaded PyPy macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

uuid_utils-0.9.0-cp312-none-win_amd64.whl (170.7 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

uuid_utils-0.9.0-cp312-cp312-musllinux_1_2_x86_64.whl (480.5 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

uuid_utils-0.9.0-cp312-cp312-musllinux_1_2_i686.whl (497.8 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ i686

uuid_utils-0.9.0-cp312-cp312-musllinux_1_2_aarch64.whl (499.1 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ ARM64

uuid_utils-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (309.4 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

uuid_utils-0.9.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (345.8 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

uuid_utils-0.9.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (314.9 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARMv7l

uuid_utils-0.9.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (319.8 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

uuid_utils-0.9.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (320.4 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.5+ i686

uuid_utils-0.9.0-cp312-cp312-macosx_10_12_x86_64.whl (270.6 kB view hashes)

Uploaded CPython 3.12 macOS 10.12+ x86-64

uuid_utils-0.9.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (532.2 kB view hashes)

Uploaded CPython 3.12 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

uuid_utils-0.9.0-cp311-none-win_amd64.whl (170.8 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

uuid_utils-0.9.0-cp311-none-win32.whl (161.7 kB view hashes)

Uploaded CPython 3.11 Windows x86

uuid_utils-0.9.0-cp311-cp311-musllinux_1_2_x86_64.whl (481.5 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

uuid_utils-0.9.0-cp311-cp311-musllinux_1_2_i686.whl (497.9 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ i686

uuid_utils-0.9.0-cp311-cp311-musllinux_1_2_aarch64.whl (499.4 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ ARM64

uuid_utils-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (310.6 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

uuid_utils-0.9.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (345.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

uuid_utils-0.9.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (315.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

uuid_utils-0.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (320.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

uuid_utils-0.9.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (322.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

uuid_utils-0.9.0-cp311-cp311-macosx_10_12_x86_64.whl (272.0 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

uuid_utils-0.9.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (534.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

uuid_utils-0.9.0-cp310-none-win_amd64.whl (171.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

uuid_utils-0.9.0-cp310-none-win32.whl (161.8 kB view hashes)

Uploaded CPython 3.10 Windows x86

uuid_utils-0.9.0-cp310-cp310-musllinux_1_2_x86_64.whl (481.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

uuid_utils-0.9.0-cp310-cp310-musllinux_1_2_i686.whl (498.1 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ i686

uuid_utils-0.9.0-cp310-cp310-musllinux_1_2_aarch64.whl (499.9 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ ARM64

uuid_utils-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (310.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

uuid_utils-0.9.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (346.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

uuid_utils-0.9.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (316.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

uuid_utils-0.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (320.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

uuid_utils-0.9.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (322.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ i686

uuid_utils-0.9.0-cp310-cp310-macosx_10_12_x86_64.whl (272.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.12+ x86-64

uuid_utils-0.9.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (534.6 kB view hashes)

Uploaded CPython 3.10 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

uuid_utils-0.9.0-cp39-none-win_amd64.whl (171.7 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

uuid_utils-0.9.0-cp39-none-win32.whl (162.3 kB view hashes)

Uploaded CPython 3.9 Windows x86

uuid_utils-0.9.0-cp39-cp39-musllinux_1_2_x86_64.whl (481.9 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

uuid_utils-0.9.0-cp39-cp39-musllinux_1_2_i686.whl (498.8 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ i686

uuid_utils-0.9.0-cp39-cp39-musllinux_1_2_aarch64.whl (500.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ ARM64

uuid_utils-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

uuid_utils-0.9.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (346.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

uuid_utils-0.9.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (317.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

uuid_utils-0.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (321.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

uuid_utils-0.9.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (323.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

uuid_utils-0.9.0-cp39-cp39-macosx_10_12_x86_64.whl (272.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.12+ x86-64

uuid_utils-0.9.0-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (536.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

uuid_utils-0.9.0-cp38-none-win_amd64.whl (171.3 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

uuid_utils-0.9.0-cp38-none-win32.whl (162.4 kB view hashes)

Uploaded CPython 3.8 Windows x86

uuid_utils-0.9.0-cp38-cp38-musllinux_1_2_x86_64.whl (481.9 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

uuid_utils-0.9.0-cp38-cp38-musllinux_1_2_i686.whl (499.0 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ i686

uuid_utils-0.9.0-cp38-cp38-musllinux_1_2_aarch64.whl (499.9 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ ARM64

uuid_utils-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

uuid_utils-0.9.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (346.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

uuid_utils-0.9.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (317.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

uuid_utils-0.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (321.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

uuid_utils-0.9.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl (323.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ i686

uuid_utils-0.9.0-cp38-cp38-macosx_10_12_x86_64.whl (272.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.12+ x86-64

uuid_utils-0.9.0-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (536.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page