image

the sleepy snake

index :: uuid :: WhatsItAnyway

What's an UUID anyway?

A UUID is a universally unique identifier. Somewhat close what to pythons id() function returns. But in contrast to id() wich is bound to an object and only guaranteed to be unique in the current process and as long as the object is alive a UUID is an abstract identifier that is supposed to be unique no matter what at least up to round about year 3400. This makes it pretty usefull to identify things like software packages, applications, data base keys (..)

A UUID generator has to be designed to make it as unlikely as possible to generate two identical UUIDs through out our solar system. Therefore the RFC 4122 standart was developed wich is adopted by this module, trying to come as close to as possible.

Note that universally unique does not mean the identifiers are universally unique. It just means that its very unlikely that two uuids are generated that compare the same. Or as wikipedia puts it a bit more elaborate: "(..) anyone can create a UUID and use it to identify something with reasonable confidence that the identifier will never be unintentionally used by anyone for anything else."

If you generate a UUID you will be confronted with a new unique 128-bit identifier like "{6ba7b814-9dad-11d1-80b4-00c04fd430c8}" you may use for any purpose you may find suitable. Some people are even known for using them for such trivial things like passwords or the like.

There are 4 types of UUIDs you can generate:

  1. time based (the UUID will be generated from a time stamp + 61 random bits)
  2. random (128 random bits that is)
  3. md5 (the UUIID will be a md5 hash that is based on a (registered) namespace UUID and a local name of your choice)
  4. sha1 (same as above but the sha1 algorithm is used for hashing)

In most cases a time based UUID should be the right choice. Final note for windows users:
UUID == GUID.


Just in case you think UUIDs can not be fun or are not useful at all see a blog entry on The Old New Thing wich may be interesting for one reason or the other.