Skip to main content

Gid
Release Linting and Tests codecov License: MIT

Gid is a small library for generating short globally unique, sortable uri safe identifiers.

Features

  • Generated ids are sortable
  • Generated ids carry creation time expressed in microseconds
  • Generated ids are globally unique
  • Minimal footprint
  • High performance

Installation

With pip,

pip install gid

or through poetry

poetry add gid

Example ids

ShmX2HaaUB9UQL02 
ShmX2JGvSk4ZyZ13 
ShmX2Ku8mDizRc23 
ShmX2MWQVL5J7022 
ShmX2OCegs4MdP22 
ShmX2Pu2MDVFHa02 
ShmX2RYngGET4Z32 
ShmX2TCM6v701q23 
ShmX2UrBjxNGYM11

Usage

Generating id

from gid import Guid

some_id = Guid()
some_id.timestamp # contains timestamp expressed in milliseconds
str(some_id) # can be cast to a string

Recreating id from string

from gid import Guid
my_id = Guid()

same_id = Guid(str(my_id))

assert same_id == my_id
assert same_id.timestamp == my_id.timestamp

Id structure

Generated identifiers are case-sensitive, which means string functions (like lowercase or uppercase) on generated identifiers may break it because Sbt5LrD9iSAwb300 is not the same value as Sbt5LrD9iSAwB300.

The below diagram represents single identifier's structure, which is 16-character long:

    Sbt5LrD9iSAwb300
    |      |      |
    +- first 7 characters for millisecond timestamp
           |      |
           +- next 7 characters is randomly generated hash
                  |
                  + last two characters to ensure uniqueness of guid in a single millisecond

Within 1 ms there can be (62^2 - 620) unique generated ids on a single machine.

Release files for gid 1.0.1

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

Source distribution (sdist)

Source distribution for gid 1.0.1
File Size Uploaded
gid-1.0.1.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gid 1.0.1
File Interpreter ABI Platform
gid-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / gid-1.0.1.tar.gz

Download URL gid-1.0.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
822c77f9129ebb37f6e8b85a46d7faca4f9ec1163cb669273f23b0a3eaa4f6bd
BLAKE2b-256 checksum
How to use checksums
22b786689440004e26be666795c04bd3a1ec1a97334f86cb5992a3301d62e6bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.8.11 Linux/5.8.0-1039-azure

Release files / gid-1.0.1-py3-none-any.whl

Download URL gid-1.0.1-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f8cd8e491416258a0c1d0244a25b75db37eef5cf271f4f8e42c9c1e662bc24b
BLAKE2b-256 checksum
How to use checksums
97cfebd1b84f1308b2b3c8f88d9592c6ca6cf54161b3a3369e2ca2fe60adac1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.8 CPython/3.8.11 Linux/5.8.0-1039-azure

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

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