As ilya n mentions, id (x) creates a unique identifier for the object.
But your question is confusing, as the hashCode Java method does not give a unique identifier. Java hashCode works like most hash functions: it always returns the same value for the same object, two identical objects always get the same codes, and unequal hash values ββimply unequal hash codes. In particular, two different and unequal objects can receive the same value.
This is confusing because the cryptographic hash functions are very different from this and are more similar (albeit not quite) to the "unique identifier" that you requested.
The Python equivalent of the hashCode Java method is hash (x).
Ned Batchelder Aug 09 '09 at 21:48 2009-08-09 21:48
source share