Skip to content

boriskurikhin/pyuniqid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyPI PyPI - Downloads License

A Unique Hexatridecimal ID generator.

Generates unique ids based on the current time, process and machine name. This package is an adaptation of a widely popular node module of the same name.

pip3 install pyuniqid

Usage

from pyuniqid import uniqid

print(uniqid()) # -> 4n5pxq24kpiob12og9

Features

  • Very fast
  • Generates unique id's on multiple processes and machines even if called at the same time.

How it works

  • With the current time the ID's are always unique in a single process.
  • With the Process ID the ID's are unique even if called at the same time from multiple processes.
  • With the MAC Address the ID's are unique even if called at the same time from multiple machines and processes.

API:

uniqid( prefix optional string , suffix optional string )

Generate unique ids based on the time, process id and mac address. Works on multiple processes and machines.

uniqid() -> "4n5pxq24kpiob12og9"
uniqid('hello-') -> "hello-4n5pxq24kpiob12og9"
uniqid('hello-', '-goodbye') -> "hello-4n5pxq24kpiob12og9-goodbye"

# usage with suffix only
uniqid('', '-goodbye') -> "4n5pxq24kpiob12og9-goodbye"

License

MIT License