Struid - "Stringy UUID" By Dale Magee BSD 3-clause License
What is it?
The Struid is an extension of python's UUID class which is intended to be more "pythonic" than the builtin UUID.
In particular, the struid makes it easy to compare with a string or integer value, e.g:
> a = Struid('deadbeef-d00f-d00f-d00f-c0ffeedecade')
> a == 'deadbeef-d00f-d00f-d00f-c0ffeedecade'
True
> a == 295990755078525382164994183696159263454
True
Struid also has convenience helpers to make it backwards-compatible with the regular uuid library:
>from struid import UUID, uuid4
>uuid4().shortstr()
'💤🎝🐆🕏🍛🐃🐉🎧💿🎻🏐💊💡'
>UUID('💤🎝🐆🕏🍛🐃🐉🎧💿🎻🏐💊💡')
UUID('fe2fdb50-9280-461e-aa46-1b3e06718995')
What else can it do?
Struids also have a new shortstr() method, which allows you to compactify your string representations of UUID values down using extended unicode characters (emojis, or any characters you choose)
e.g:
> a = Struid('deadbeef-d00f-d00f-d00f-c0ffeedecade')
> a.shortstr()
'🌨🚩💵👤🚡ᚮ🕓💣🐙😝🕴🕤ᛦ'
And you can also instantiate a struid from a shortstr, or compare with one:
> Struid('🌨🚩💵👤🚡ᚮ🕓💣🐙😝🕴🕤ᛦ')
Struid('deadbeef-d00f-d00f-d00f-c0ffeedecade')
You can change the available characters shortstr() can use by calling struid.set_digits(), e.g:
> import struid
> struid.set_digits("0123456789AbCdEf")
> a=Struid('deadbeef-d00f-d00f-d00f-c0ffeedecade')
> a.shortstr()
'dEAdbEEfd00fd00fd00fC0ffEEdECAdE'
(note that changing the available characters affects the shortstr for all guids, so if you e.g save shortstrings to a file and then change character sets, the shortstrings in the file will no longer match)
What else do I need to know?
Struids are built to be case-insensitive, i.e you must not include both upper and lowercase of the same character in the SHORTSTR_DIGITS, doing so will cause breakage.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file struid-0.0.5.tar.gz.
File metadata
- Download URL: struid-0.0.5.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/5.1.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bca6e2ae6c2825191496a7e5ccf72b634ccaa9fffe370efb75f5a1901999fbbb
|
|
| MD5 |
fe8de69d523672adb9388f59678e5d8e
|
|
| BLAKE2b-256 |
d70886c6a0f3792bdec46a2cff026c767f613e83e9ee4570fbcd0a6abf60a016
|
File details
Details for the file struid-0.0.5-py3-none-any.whl.
File metadata
- Download URL: struid-0.0.5-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/5.1.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50bdcbcf78aab0ff68247384bd4ad97839be472dbee07326520971004904fe7f
|
|
| MD5 |
7865a955b413c247249871a68187ef58
|
|
| BLAKE2b-256 |
3cd1a134f2bbb9b540933aa3c6531e76028ffe37c5dfae82c199c8c9c7ea35f4
|