Generating unique numbers?
Christopher Browne
cbbrowne at acm.org
Sat Jun 1 02:32:48 EDT 2002
A long time ago, in a galaxy far, far away, xscottgjunk at yahoo.com (Scott Gilbert) wrote:
> 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.
And GUIDs are basically DCE UUIDs.
<http://packages.debian.org/stable/devel/uuid-dev.html>
<http://www.gnuenterprise.org/doc/uuid-dev/>
I think this is all C stuff; it oughtn't be _too_ difficult to wrap it
into a Python library...
--
(concatenate 'string "cbbrowne" "@ntlug.org")
http://www.ntlug.org/~cbbrowne/oses.html
All things are possible except skiing through a revolving door.
-- DeMara Cabrera
More information about the Python-list
mailing list