You are here: Home V2 Software Software More ... Memops Code Generation Strategy Documents Universal IDs (GUID/UUID)

Universal IDs (GUID/UUID)

Globally unique IDs - which to use and how to generate them Rasmus Fogh 2007


GUIDs are needed for MetaModel objects, and  for API TopObjects. As of May 2007 the same homemade GUID generator is used for both, based on user name, organisation, exact time stamp, and an incremented integer. This is rather weak. It should be OK for MetaModel Elements, created in few places and slowly, but ought to be replaced by something better for TopObjects. See below for possibilities.

NOTE: Python 2.5 and higher has a built-in uuid module. You can chose between versions based on time, node-IDs and fully random.


Generation of universal IDs is still a developing field, apparently. A quick google turns up

which are new since Peter sent out his summarising mail

For the time being I am using the uuid generator from

(in Peters mail). This uses system uuid generators if available, and degrades to pure Python otherwise. As I only need it for the MetaModel there is no need to agonise over the choice. We shall probably need a more careful consideration when we start generating guids for top objects.


Peter Kellers original  literature references: - particularly

OMG lifecycle spec

Some early useful links:

Ludovic Lauer: Concerning Unique Identifiers (
Peter Keller:
Rasmus Fogh:


The authoritative answer (Peter Keller):
Subject: Re: Core CCPN meeting

Hi Rasmus,

> - The topObjects will have a GUID an (automatically generated) global
> universal identifier as its key. GUIDs are generated in such a way as to
> eb globally unique, and serve to keep track of objects as you move them
> around, merge them, etc. The GUID will be used in all internal object
> references, like interpackage XML links.

> Peter Keller is looking into a standard and code to make GUIDs.

Result: the code to make uuid's is part of the e2fsprogs package (because
it was originally developed to generate uuid's for ext2 filesystems). The
home page is here:

If it is already installed on your system, you should be able to do:

man 3 uuid_generate

You can download the file e2fsprogs-libs-xxx.tar.gz from sourceforge,
which contains only the libraries from the suite (including libuuid) -
this has been packaged specifically so that they can be built and used
independently of the tools to manage ext2 filesystems. I'll try building
it on my SPARC/Solaris system over the weekend, but it looks reasonably

For python: there are two implementations using the e2fsprogs ideas that I
have found.

The first is a python wrapper that uses libuuid if installed, otherwise it
falls back on an internal python implementation. The thread starts at . Follow
this thread through to the end if you decide to use it - various people
have suggested various changes. I don't know if this has been included in
any standard modules or distributions.

The second seems to be on my system already:

[bernoulli]~-130 > locate

[bernoulli]~-135 > python
Python 2.3.4 (#1, Feb  2 2005, 11:44:49)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Ft.Lib import Uuid
>>> dir(Uuid)
['CompareUuids', 'GenerateUuid', 'GetEthernetNode', 'GetRandomBytes',
'UuidAsString', '__builtins__', '__doc__', '__file__', '__name__',
'dev_rand', 'rng', 'socket']

This is a pure-python implementation, so is likely to be slow. Once again,
it is based on the e2fsprogs work.

There are several possibilities for window$:

Distribute a mingw-compiled version of libuuid

Find some other way of extracting a uuid from the system

Stick to a pure-python implementation and recommend that people switch
to *ix if they think it is too slow.

Just for fun, I also found this on-line