[ZODB-Dev] Unique Object ID

Steve Alexander steve at cat-box.net
Thu Jun 5 14:16:47 EDT 2003


> BTW: Zope Catalog uses (in 2.7 head) random.randint(-2000000000, 2000000000) 
> to generate record ids. It then double-checks that the id hasn't already been 
> taken. This should probably also be done if you use a counter just to be 
> safe. Performance here isn't really an issue, since relative to writing to 
> the database, generating a random number is not expensive.
> 
> Actually Catalog uses a combination of random and sequencial ids. That way if 
> many objects are added at once, they tend to cluster in the BTree data 
> structure minimizing the number of nodes and buckets that need to be touched. 
> Have a look at the catalogObject method of Catalog.py in the Zope head.

The ObjectHub in zope 3 uses something similar, except that 0 is never 
used as an id. So, ids are always __nonzero__.

--
Steve Alexander




More information about the ZODB-Dev mailing list