On Wed, Dec 24, 2008 at 10:05 AM, Tim Roberts <span dir="ltr"><<a href="mailto:timr@probo.com">timr@probo.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000"><div class="Ih2E3d">
<br></div>
But, this has to be considered a rather serious bug, doesn't it? If I
create an object p2, then insert it into a list at l[0], the Python
contract guarantees that l[0] and p2 are references to the same object,
so that modifying one must modify the other.<br>
</div></blockquote><div><br>CLR value types simply don't map well onto Python objects, because CPython doesn't have any value types. All objects are basically references. In the CLR, we convert value types into reference types by "boxing" them, and it's only in this state that they have an "identity". When a value type is unboxed and reboxed, it acquires a whole new identity, and therefore a new "id". If you're familiar with the CPython "C" language API, you can think of this as the distinction between the numeric value stored inside an "int" PyObject, and the PyObject itself.<br>
<br>I believe that the current "best practices" for CLR value types are to encourage people to treat them as immutable. If you do this, the lack of reference equality is no longer quite as important :).<br><br>
I don't know whether or not the specific behavior you've identified is a bug, but you should definitely enter it into CodePlex so that it can be tracked and investigated properly.<br><br>--<br>Curt Hagenlocher<br>
<a href="mailto:curt@hagenlocher.org">curt@hagenlocher.org</a><br></div></div>