Uniquely generated string identifiers
Project description
This package generates unique string identifiers.
from ustrid import ustrid
unique_string_id = ustrid()
Under the hood:
import uuid
import threading
def ustrid():
"""Generate a unique string identifier (thread-safe)"""
return Ustrid.run()
class Ustrid:
"""Private class to generate unique string identifiers (thread-safe)"""
_lock = threading.Lock()
_count = 0
@classmethod
def run(cls):
"""Generate a unique string identifier (thread-safe)"""
with cls._lock:
cls._count += 1
return "{}-{}".format(cls._count, uuid.uuid4())
Installation:
pip install ustrid
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ustrid-0.0.3.tar.gz
(3.2 kB
view hashes)
Built Distribution
ustrid-0.0.3-py3-none-any.whl
(4.1 kB
view hashes)