Message9
According to the Python library documentation, the "id" builtin
function will return unique integers for different objects. The
documentation for java's hashCode makes no such garantee. The new
hotspot VM change the behavior of the JDK and the hashCode (and
identifyHashCode) function can return the same integer for different
objects.
pickle.py assumes that id() returns unique values.
======= From Python docs "__builtin__.id()"=========
Return the `identity' of an object. This is an integer which is
guaranteed to be unique and constant for this object during its
lifetime.
======= From Java docs "Object.hashCode()" =========
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct objects.
(This is typically implemented by converting the internal address of
the object into an integer, but this implementation technique is not
required by the JavaTM programming language.)
--------- FILE: test099.py ---------
d = {}
for i in xrange(100000):
s = "test" + `i`
j = id(s)
if d.has_key(j):
print "Duplicate id %s<%d> & %s<%d>" % (s, j, d[j],
id(d[j]))
d[j] = s
--------- END ---------
|
|
| Date |
User |
Action |
Args |
| 2008-02-20 17:16:37 | admin | link | issue222789 messages |
| 2008-02-20 17:16:37 | admin | create | |
|