[pypy-dev] Object identity and dict strategies

Alex Gaynor alex.gaynor at gmail.com
Fri Jul 8 01:49:33 CEST 2011


Hi all,

I've now spoken with several developers about the object identity that
arises out of hte new dict strategies, and all seem to think that the
current implementation breaks Python's semantics, that is:

x = 3
z = {x: None}
assert next(iter(z)) is x

will fail.  The only solution I see to this that maintains the correct
semantics in all cases is to specialize is/id() for primitive types.  That
is to say, all integers of any given value have the same id() and x is y is
true.  Doing x is y is true is easy, you simply have a multimethod which
dispatches on the types and compares intval for W_IntObjects (objects of
differing types can never have the same identity) however the question is
what to use for id() that is unique, never changes for an int, and doesn't
intersect with any other live object.  In particular the last constraint is
the most difficult I think.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20110707/5e01f77f/attachment.html>


More information about the pypy-dev mailing list