unique number generator

Harry George harry.g.george at boeing.com
Wed May 19 12:03:39 EDT 2004


"Joe Wong" <joewong at mango.cc> writes:

> Hi,
> 
> There is a constraint that the number can be at most 8 digits, ie:
> 
> 00000000 ~ 99999999
> 
> No hex decimal is allowed...
> 
> And I am on Linux platform..
> 
> Any other suggestion? :-)
> 

I hope you get to control all the generators for this number.
Otherwise different algorithms may accidentally overlap even if they
are properly unique in their own streams.

Given that, you need a unique number up to 1e9.  

1. If you can get the traditional GUID based on MAC+timestamp+random,
   you might hash that down to a digital signature in your number
   range.  This increases the possibility of overlaps, but it might be
   acceptable in your context.  E.g., do an md5 on your guid and take
   the lower 7 hex digits.

2. If there are characteristics of the problem space which are
   themselves unique, then you might do a canonical mapping from that
   to integers.  If you are lucky, this could be a dense mapping (no
   skipped integers), and thus able to support a billion unique items.


-- 
harry.g.george at boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007



More information about the Python-list mailing list