On Wed, Dec 24, 2008 at 10:05 AM, Tim Roberts <span dir="ltr">&lt;<a href="mailto:timr@probo.com">timr@probo.com</a>&gt;</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&#39;t it?&nbsp; 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&#39;t map well onto Python objects, because CPython doesn&#39;t have any value types.&nbsp; All objects are basically references.&nbsp; In the CLR, we convert value types into reference types by &quot;boxing&quot; them, and it&#39;s only in this state that they have an &quot;identity&quot;.&nbsp; When a value type is unboxed and reboxed, it acquires a whole new identity, and therefore a new &quot;id&quot;.&nbsp; If you&#39;re familiar with the CPython &quot;C&quot; language API, you can think of this as the distinction between the numeric value stored inside an &quot;int&quot; PyObject, and the PyObject itself.<br>
<br>I believe that the current &quot;best practices&quot; for CLR value types are to encourage people to treat them as immutable.&nbsp; If you do this, the lack of reference equality is no longer quite as important :).<br><br>
I don&#39;t know whether or not the specific behavior you&#39;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>