portable uuid module

Martin Pool mbp at sourcefrog.net
Fri Apr 15 23:47:40 BST 2005

On Fri, 2005-04-15 at 11:34 -0700, Matt Mackall wrote:
> On Fri, Apr 15, 2005 at 05:15:22PM +0200, Denys Duchier wrote:
> > I noticed that osutils.py bemoans the lack of a portable uuid implementation.  I
> > have written one and I attach it below.  uuid.py contains a pure python
> > implementation of the algorithm used by Theodore Tso's libuuid, it is also able
> > to take advantage of libuuid if it is present on your system, and it can also
> > use the Linux /proc/sys/kernel/random/uuid interface if available.  You always
> > automatically get the fastest implementation available.

That's great.

One improvement (which may not be worthwhile) would be to allow getting
the UUIDs back in binary form rather than hex.  Sometimes they are
packed into binary structures, though I've never done that in Python.

> One often raised complaint about such UUIDs is that they're based on
> MAC addresses that can be matched against particular machines. Not
> sure if that's a problem here.

For those people there's generate_random(), which does not depend on the

I don't actually use UUIDs for anything at the moment, but rather random
strings like this:

mbp at sourcefrog.net-20050408220755-b6fac9649ee0ebb51864ef07

I think the collision probability is adequately low and they're somewhat
easier to handle if a person ever sees them.  One drawback is that they
do not pack down to 16 bytes.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050416/e2232308/attachment.pgp 

More information about the bazaar mailing list