[ZODB-Dev] Unique Object ID

John J Lee jjl at pobox.com
Wed Jun 4 23:35:50 EDT 2003


On 4 Jun 2003, Johan Dahlin wrote:
[...]
> They are keyed by the id of the object. In the current invocation of
> IndexedCatalog we have been using id() of the object (eg the memory
> address) as the id of the object.
>
> Recently we have found out that it's not very reliable, since it might
[...]
> 1) use _p_oid
[...]
> 2) Using a counter, increase it for each object
[...]
> Am I missing something, or is it another way of doing this?
> Comments, suggestions highly appreciated.

How about the random module?

If that's too slow, maybe even just hash((obj.id(), time.time()))?
Obviously you need to make sure the hash function has a big enough range
for your purpose, though.

I know things like MS COM use GUIDs where the G *really* means global
(based on network card MAC address, current time and a counter), which are
truly unique, not 'just' statistically.  Googling found this, probably
OTT:

http://www.webdav.org/specs/draft-leach-uuids-guids-01.txt


The truth is that you're more likely to be run over by a bus driven by
Guido than to find a statistical GUID clash, so I'd just use the random
module.


John




More information about the ZODB-Dev mailing list