Skip to main content

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


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)

Uploaded Source

Built Distribution

ustrid-0.0.3-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

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