[Numpy-discussion] Should ndarray be a context manager?
Sturla Molden
sturla.molden at gmail.com
Fri Dec 12 03:18:02 EST 2014
Chris Barker <chris.barker at noaa.gov> wrote:
> Anyway, the point is that if we wanted this to be a
> used-more-than-very-rarely in only very special cases feature de-allocating
> an array's data buffer), then ndarray would need to grow a check for an
> invalid buffer on access.
One would probably need something like Java JNI where an array can be
"locked" by the C code.
But nevertheless, what I suggested is not inherently worse than this C++
code:
{
std::vector<double> a(n);
// do something with a
}
// references to std::vector a might still exist
In C this is often known as the "dangling pointer" problem.
Sturla
More information about the NumPy-Discussion
mailing list