Skip to main content

uqid:

pip install uqid
from uqid import uqid, digits

print(uqid()) # e7ljCIs4grYZ9tOv6bpX3TQIA7FyA23umzGjDcIjHff2XwF2ziAw56B7S3EdOuCA
print(uqid(4, digits)) # 4982
  • Returns unique id from random chars.

  • Default is 64 chars 0-9a-zA-Z aka base62.

dtid:

pip install uqid
from uqid import dtid
print(dtid())

YYYYMMDDhhmmssmicrosrnd4
20161231235959123456uN1q
  • 24 bytes by default - as str(ObjectId()).

  • But human-friendly - unlike ObjectId.

  • Microsecond-precise UTC timestamp - unlike second-precise ObjectId().

  • May extract datetime_from_dtid().

  • May be used as a log timestamp as is.

  • Alphabetically ordered.

  • Safe chars 0-9a-zA-Z - unlike binary ObjectId() leading to “ValueError: Invalid UTF-8 sequence length” if added to JSON without str().

  • base62^4 is over 14M uniques per microsecond.

  • dtid(24) is 2x faster than uqid(24) but slower than str(ObjectId())

tests:

python2 uqid.py
python3 uqid.py

SAMPLES:
str(uuid4()): 3bb25137-2422-4d06-bd12-5a9de2ea2bf6
len(^): 36
len(v): 24
str(ObjectId()): 5acdcd1f9c591516ae800615
uqid(24): UFRFQVCtYu6rtQq8LD33XjI3
dtid(24): 20180411085351268116tHse
Iterations: 1000000

python2 SECONDS:
str(uuid4()) seconds: 11.825964
str(ObjectId()) seconds: 2.424702
uqid(24) seconds: 9.701306
dtid(24) seconds: 5.357983

python3 SECONDS:
str(uuid4()) seconds: 5.826098
str(ObjectId()) seconds: 3.192565
uqid(24) seconds: 17.769653
dtid(24) seconds: 9.588677

DUPLICATES:
str(uuid4()) duplicates: 0
str(ObjectId()) duplicates: 0
uqid(24) duplicates: 0
dtid(24) duplicates: 0

Release files for uqid 0.3.0

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

Source distribution (sdist)

Source distribution for uqid 0.3.0
File Size Uploaded
uqid-0.3.0.tar.gz 2.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for uqid 0.3.0
File Interpreter ABI Platform
uqid-0.3.0-py3-none-any.whl Python 3 none any Details
uqid-0.3.0-py2-none-any.whl Python 2 none any Details

Total release size: 12.3 kB

Release files / uqid-0.3.0.tar.gz

Download URL uqid-0.3.0.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
edee2fc48c5feed999d95bc88755a57b9e94dd8405d23bc4a4afb87c58b18d78
BLAKE2b-256 checksum
How to use checksums
31b18692e13be884be7d6dd9ea6478421ae53a8d9c43d696d3fa0df81f0c7346
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / uqid-0.3.0-py3-none-any.whl

Download URL uqid-0.3.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc3adebc79462e4cea107b7e93ba00c59702ff25c587ecdf97dd26906578038c
BLAKE2b-256 checksum
How to use checksums
5be5eb5c81e2266280593d8969ca1fa60b33b6f41ce638329bd8de4061857276
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / uqid-0.3.0-py2-none-any.whl

Download URL uqid-0.3.0-py2-none-any.whl
Size 4.7 kB
Tags Python 2
SHA-256 checksum
How to use checksums
61cfa4ed07b6166ae81b76937cdc302c4ee396f2bc80f98d50604392b9ce0f5c
BLAKE2b-256 checksum
How to use checksums
ecfb0500e1c4a7266d52585646cc51ed9fbdd96d9f646e34f7ae42bfb0b91be5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.0 This release

3 release files

0.2.0

1 release file

0.1.0

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