Skip to main content
https://img.shields.io/pypi/v/smalluuid.svg https://img.shields.io/pypi/dm/smalluuid.svg https://img.shields.io/github/license/adamcharnock/smalluuid.svg https://img.shields.io/travis/adamcharnock/smalluuid.svg https://coveralls.io/repos/adamcharnock/smalluuid/badge.svg

Installation

Installation using pip:

pip install smalluuid

Basic Usage

A drop-in replacement for Python’s UUID class which – by default – represents UUIDs as 22 character base64-encoded values.

>>> from smalluuid import SmallUUID
>>> uuid = SmallUUID()

# Displays as short UUID by default
>>> uuid
SmallUUID('IBNApQOzTHGzdjkSt6t-Jg')
>>> print(uuid)
IBNApQOzTHGzdjkSt6t-Jg

# Hex output still available
>>> SmallUUID().hex
'44a30f95b86f429f83c5669fed1998ab'
>>> uuid.hex_grouped
'201340a5-03b3-4c71-b376-3912b7ab7e26'

# Will initialise from short UUID
>>> SmallUUID('IBNApQOzTHGzdjkSt6t-Jg')
SmallUUID('IBNApQOzTHGzdjkSt6t-Jg')

# Will load as a hex value
>>> SmallUUID(hex='201340a5-03b3-4c71-b376-3912b7ab7e26')
SmallUUID('RKMPlbhvQp-DxWaf7RmYqw')

Notable differences from Python’s UUID implementation:

  • Short-form UUIDs accepted as first parameter to __init__

  • Instantiating without a value will assign a random value of the given version (default: 4) rather than raise an exception.

  • Addition of hex_grouped property to provide access to grouped hex style UUIDs, formally provided by __str__.

Typed UUID Usage

An extension of SmallUUID is available in the form of TypedSmallUUID:

>>> from smalluuid import TypedSmallUUID

# Takes a type during instantiation
>>> uuid = TypedSmallUUID(type=42)
>>> uuid
TypedSmallUUID('qHHvXuUwT6y7t7dnsiksvg')

# Type is stored within the UUID
>>> uuid.type
42

# Type determined from provided UUID value
>>> TypedSmallUUID('qHHvXuUwT6y7t7dnsiksvg').type
42

The use case here is that of having UUIDs from which one can determine both an object’s ID and the object’s type/table/model.

Credits

Any credits here

This project borrowed a little code and inspiration from shortuuid.

smalluuid is packaged using seed.

Metadata

Release files for smalluuid 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smalluuid 0.1.4
File Size Uploaded
smalluuid-0.1.4.tar.gz 204.7 kB Details

Release files / smalluuid-0.1.4.tar.gz

Download URL smalluuid-0.1.4.tar.gz
Size 204.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e3e72003d99dfe2a7879bbd09f0f7480ae7f90fce033adb76a27f011f0190589
BLAKE2b-256 checksum
How to use checksums
848bcfb3d48323fea41ed12b2a7210fa9bc2d62872fd7ebbf2903bdcec056092
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.1.0

2 release files

1.0.0

2 release files

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page