fast_uuid#

fast_uuid(which=None, length=None, n=1, secure=False, forcelist=False, safety=1000, recursion=0, recursion_limit=10, verbose=True)[source]#

Create a fast UID or set of UIDs. Note: for certain applications, sc.uuid() is faster than sc.fast_uuid()!

Parameters:
  • which (str) – the set of characters to choose from (default ascii)

  • length (int) – length of UID (default 6)

  • n (int) – number of UIDs to generate

  • secure (bool) – whether to generate random numbers from sources provided by the operating system

  • forcelist (bool) – whether or not to return a list even for a single UID (used for recursive calls)

  • safety (float) – ensure that the space of possible UIDs is at least this much larger than the number requested

  • recursion (int) – the recursion level of the call (since the function calls itself if not all UIDs are unique)

  • recursion_limit (int) – Maximum number of times to try regeneraring keys

  • verbose (bool) – whether to show progress

Returns:

a string UID, or a list of string UIDs

Return type:

uid (str or list)

Example:

uuids = sc.fast_uuid(n=100) # Generate 100 UUIDs

Inspired by https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits/30038250#30038250