<br><br><div><span class="gmail_quote">On 8/29/07, <b class="gmail_sendername">Anne Archibald</b> <<a href="mailto:peridot.faceted@gmail.com">peridot.faceted@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 29/08/2007, Timothy Hochberg <<a href="mailto:tim.hochberg@ieee.org">tim.hochberg@ieee.org</a>> wrote:<br><br>> The main inconsistency I see above is that resize appears to only require<br>> ownership of the data if in fact the number of items changes. I don't think
<br>> that's actually a bug, but I don't like it much; I would prefer that resize<br>> be strict and always require ownership. However, I'm fairly certain that<br>> there are people that prefer "friendliness" over consistency, so I wouldn't
<br>> be surprised to get some pushback on changing that.<br><br>It seems to me like inplace resize is a problem, no matter how you<br>implement it --- is there any way to verify that no view exists of a<br>given array? (refcounts won't do it since there are other, non-view
<br>ways to increase the refcount of an array.) </blockquote><div><br>I think that may be overstating the problem a bit; refcounts should work in the sense that they would prevent segfaults. They'll just be too conservative in many cases, preventing resizes in cases where they would otherwise work.
<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If there's a view of an<br>array, you resize() it in place, and realloc() moves the data, the
<br>views now point to bogus memory: you can cause the python interpreter<br>to segfault by addressing their contents. I really can't see any way<br>around this; why not remove inplace resize() (or make it raise<br>exceptions if the size has to change) and allow only the function
<br>resize()?</blockquote><div><br>Probably because in a few cases, it's vastly more efficient to realloc the data than to copy it.  <br><br>FWIW, I don't use either the resize function or the resize method, but if I was going to get rid of one, personally I'd axe the function. Resizing is a confusing operation and the function doesn't have the possibility of better efficiency to justify it's existence.
<br></div></div><br clear="all"><br>-- <br>.  __<br>.   |-\<br>.<br>.  <a href="mailto:tim.hochberg@ieee.org">tim.hochberg@ieee.org</a>