"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tue, 19 Jul 2005 10:20:04 +0200, Glauco wrote: > >>> The only niggly worry I have is I'm not sure when hash can be used, >>> when >>> it is unique, or even if is it guaranteed to be unique. >>> >> >> Thank Steve, the idea was the same... >> but yours using hash is much elegant. > > I'm still worried about hash of two unrelated objects returning the same > value. > > Another implementation is to keep a hidden attribute of the object, and > initialise it to the integer 0. Instead of using hash(key), you use the > current value of the integer, then increment the integer by one. > > This is guaranteed to be unique, no matter what.
id(ob) is already guaranteed to be a unique integer while ob exists. So, if I understand the goal, map possibly-multiple-keys each to id and id to ob. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list