necaris / cuid.py

A fast, scalable unique ID generator for Python
BSD 2-Clause "Simplified" License
64 stars 8 forks source link

Is it possible to generate slug with 8 or nine chars? #10

Closed luiscoms closed 7 years ago

luiscoms commented 7 years ago

Once I generate a bunch of slugs, i need to increase the size of slug to be able to generate more of them. Is it possible? Thanks

necaris commented 7 years ago

In order to maintain API compatibility with the specification and other implementations I'm reluctant to change how slug() works. If you need a longer slug, why don't you use a full cuid()?

luiscoms commented 7 years ago

I see, I don`t want to use full cuid cause it is too long.

necaris commented 7 years ago

It sounds like you want to shorten the full cuid. If you simply take every 2nd or every 3rd character from the cuid, this will preserve other useful properties (like sorting) -- for example:

>>> short_cuid = cuid.cuid()[::2]
>>> len(short_cuid) # 13
>>> shorter_cuid = cuid.cuid()[::3]
>>> len(shorter_cuid) # 9

If you're not so concerned about uniqueness, this should work.

necaris commented 7 years ago

Closing this issue since we have an alternative solution.