[Q]:Generate Unique ID's

Paul Rubin http
Sat May 24 00:34:18 EDT 2003


"Terry Reedy" <tjreedy at udel.edu> writes:
> Hmm.  How about this for the OP.  I believe the new 2.3 rng has a
> period many bits longer than 2^32.  So start with a seed for machine
> one.  Generate, say, 1 billion pseudo rns.  That is the starting key
> for machine two.  Repeat for machine three.  As long as a machine
> needs less than 1 billion ids over the life of the project, all should
> be well.  Problem solved?

No, absolutely not.  If there's only 2^32 states in the RNG you can
expect to see duplicate UUID's after 2^16 rn's or so.  It's the same
principle as the "birthday paradox", which says that if you have 25
people in a room, it's more likely than not that some two of them will
have the same birthday.

Also, 2^32 rn's may not be enough.  All we know is that it's for a
database application.  There are lots of databases with more than 2^32
records.




More information about the Python-list mailing list