<div dir="ltr">I'm stumped. I can't figure out how to extract from e.g. <div><br></div><div>view = A[:, 3]</div><div><br></div><div>that the view starts at element 3 of A. I was planning to make a may_share_memory implementation based on the idea of swapping in a buffer of 0s, and using the shapes, strides, itemsize etc. to increment just the parts of the 0s buffer touched by the two ndarrays. If there  are any 2s in the incremented buffer, it's because the two views overlapped. It's not the best algorithm for comparing tiny views of huge arrays, I was wondering if in my case it would have been quicker than the built-in method (I don't know how it works). I actually have another data structure around to pull out that shape and stride info, but it's a shame to use it, because then I can't use the algorithm to compare ndarrays in general (or at least ones that have been created by typical construction methods and slicing).</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 6, 2013 at 12:48 PM, James Bergstra <span dir="ltr"><<a href="mailto:bergstrj@iro.umontreal.ca" target="_blank">bergstrj@iro.umontreal.ca</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for the tips! FWIW my guess is that since '.data' is dynamically generated property rather than an attribute, it is being freed and re-allocated in the loop, and once for each of my id() expressions.</div>


<div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Fri, Sep 6, 2013 at 12:32 PM, Charles R Harris <span dir="ltr"><<a href="mailto:charlesr.harris@gmail.com" target="_blank">charlesr.harris@gmail.com</a>></span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>

On Fri, Sep 6, 2013 at 10:19 AM, James Bergstra <span dir="ltr"><<a href="mailto:bergstrj@iro.umontreal.ca" target="_blank">bergstrj@iro.umontreal.ca</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hi, could someone help me understand why this assertion fails?</div>



<div><br></div><div>def test_is(self):</div><div>    a = np.empty(1)</div><div>    b = np.empty(1)</div><div>    if a.data is not b.data:</div>

<div>        assert id(a.data) != id(b.data) # <-- fail</div><div><br></div><div>I'm trying to write an alternate may_share_memory function.</div><div><br></div></div></div></blockquote><div><br></div></div></div>


<div>id seems not as advertised:<br>
<br>In [22]: for i in range(10): print id(a.data)<br>66094640<br>66095792<br>66095792<br>66095792<br>66095792<br>66095792<br>66094640<br>66094640<br>66094640<br>66094640<br><br></div><div>Not sure why.<br><br></div><div>


Chuck<br>
</div></div></div></div>
<br></div></div><div class="im">_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></div></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><a href="http://www-etud.iro.umontreal.ca/~bergstrj" target="_blank">http://www-etud.iro.umontreal.ca/~bergstrj</a>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><a href="http://www-etud.iro.umontreal.ca/~bergstrj" target="_blank">http://www-etud.iro.umontreal.ca/~bergstrj</a>
</div>