Generating unique numbers?

Scott Gilbert xscottgjunk at yahoo.com
Sat Jun 1 01:36:43 EDT 2002


VanL <vlindberg at verio.net> wrote in message news:<3CF7EBC8.4080802 at verio.net>...
> Is there a good algorithm for generating unique numbers 
> (ints, specifically) that can be used as object identifiers?
> 
> I am discounding the obvious newid += 1 because I will need 
> to merge different sets, and while I may have some number 
> overlap, using a simple count for each object would 
> guarantee that I have the maximum number of clashes.
> 
> Specifically, I will be using these numbers as dictionary keys.
> 

If you're on windows, you could use the pythoncom module CreateGuid
function.

Basically GUIDs are 128 bit numbers that are pretty much going to be
unique no matter where or when you call the function.



More information about the Python-list mailing list