[Numpy-discussion] can't resize ndarray subclass
tim.hochberg at cox.net
Tue Feb 28 14:06:09 EST 2006
Travis Oliphant wrote:
> Zachary Pincus wrote:
>> However a new problem has me nearly tearing my hair out. Calling the
>> resize method on an instance of such a subclass works fine. However,
>> calling a method that calls 'self.resize' breaks! And worse, it
>> breaks in such a way that then subsequent calls to resize also break.
> In SVN version of numpy, there is a new keyword argument to resize
> (refcheck). If this keyword argument is 0 (it defaults to 1), the
> reference-count check is not performed. Thus, if you are sure that
> your array has not exposed it's memory to another object, then you can
> set refcheck=0 and the resize will proceed.
I'd suggest that this get exposed as a separate function, for instance
A._unchecked_resize(size). It seems much less likely that this will
accidentally get called than that somone will mistakenly throw a second
boolean argument into resize.
> If you really did expose your memory to another object, this could
> lead to segfaults in exactly the same way that exposing the memory to
> a Python array (array module) and then later resizing (which Python
> currently allows) would cause problems.
> Be careful...
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> that extends applications into web and mobile media. Attend the live
> and join the prime developer group breaking into this new coding
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
More information about the NumPy-Discussion