[Numpy-discussion] Creating PyArrayObject in C++

Stéfan van der Walt stefan@sun.ac...
Tue Jul 7 17:20:16 CDT 2009


Hi Kenny

2009/7/7 Kenny Abernathy <kenny.abernathy@gmail.com>:
> I can guarantee that all analysis will be finished before the Unit object is
> destroyed and delete[] is called, so I don't think that's a problem.

There is a neat trick to make sure things don't get deallocated out of order:

http://blog.enthought.com/?p=62

>  However, what if there are modifications to the array from within a Python
> script (specifically changes to the number of elements in the array).  I
> should be able to get the new size from PyArrayObject, but will it have any
> effect on the delete[] operation?

NumPy won't reallocate any of your memory if you set the array flag
OWNDATA to False, so it should be safe to deallocate as usual.

Regards
Stéfan


More information about the NumPy-Discussion mailing list