[Numpy-discussion] Should ndarray be a context manager?
Chris Barker
chris.barker at noaa.gov
Thu Dec 11 16:30:32 EST 2014
On Wed, Dec 10, 2014 at 8:40 PM, Sturla Molden <sturla.molden at gmail.com>
wrote:
> > I haven't managed to trigger a segfault yet but it sure looks like I
> > could...
>
> You can also trigger random errors. If the array is small, Python's memory
> mamager might keep the memory in the heap for reuse by PyMem_Malloc. And
> then you can actually modify some random Python object with bogus bits. It
> can screw things up even if you do not see a segfault.
>
I should have said that -- I did see random garbage -- just not an actual
segfault -- probably didn't allocate a large enough array for the system to
reclaim that memory.
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.
I have no idea if that would make for a noticeable performance hit.
-Chris
>
> --
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141211/3de106fd/attachment.html>
More information about the NumPy-Discussion
mailing list