Python uuid4 VS token_urlsafe to generate unique identifiers?

  python, python-3.x

I need to generate unique (and unguessable) ids for my app, so the obvious choice is to use uuids, as they are designed exactly for that need.

However, I’m wondering how using secrets.token_urlsafe() method would differ for this purpose?

Is token_urlsafe as efficient as uuid4 to avoid a potential collision when generating a key?

And if yes, are there any reason to keep using uuids?

Source: Python-3x Questions

LEAVE A COMMENT