zyli5313 / cuid.py

A fast, scalable unique ID generator for Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cuid.py Build Status

Implementation of https://github.com/ericelliott/cuid in Python.

A cuid is a portable and sequentially-ordered unique identifier designed for horizontal scalability and speed -- this version is ported from the reference implementation in Javascript.

Tested on CPython 2.7-3.6 as well as PyPy & PyPy3 -- see Travis-CI link above.

Rough benchmarks on my machine (mid-2014 Macbook Pro, 2.8GHz i7) using setup.py bench (which times the creation of 1 million cuids):

Version ns / cuid
CPython 3.6 11368
CPython 3.5 9834
CPython 3.4 9665
CPython 2.7 8869
PyPy 5.6.0 508

(Note that timing the creation of fewer IDs changes the way PyPy runs the code, because of JIT warmup -- obviously creating this many IDs takes advantage of the warmed JIT)

Note: For now, this has no dependencies outside the standard library -- in time this may change, to provide better random numbers and / or performance.

About

A fast, scalable unique ID generator for Python


Languages

Language:Python 99.3%Language:Batchfile 0.5%Language:Shell 0.2%