[SciPy-user] [Numpy-discussion] Need more comments from scientific community on python-dev
prabhu at aero.iitb.ac.in
Wed Nov 1 03:53:21 CST 2006
>>>>> "Travis" == Travis Oliphant <oliphant at ee.byu.edu> writes:
Travis> 2) Examples of sharing memory between two objects. PIL is
Travis> the classic example and has some merit, but because the
Travis> internal memory layout of the PIL is 'pointer-to-pointers'
Travis> instead of 'big-chunk-of-memory' it's not a 1-1 match to
Travis> NumPy and the array interface only can comunicate
Travis> information about the "mode." But, I can see other
Travis> examples. PyMedia, PyGame, PyVideo? CVXOPT, PyVoxel.
VTK-Python and TVTK use this. Right now these use the buffer protocol
to allow users to pass numpy data into a vtkDataArray. It works
reasonably well. The VTK data arrays have type information so it is
not absolutely essential for an extended buffer protocol here. TVTK
uses this underlying functionality in VTK to present a cleaner
interface. The idea is to have VTK use the data setup and manipulated
by numpy without an expensive copy. The only caveat is that you need
to hang on to a reference of the numpy array if not you will end up
with a segfault.
I just thought this might be a useful data point.
FWIW, I am all for ndarrays/extended buffers in Python core. It would
encourage a standard way to pass data in and out of wrapped code.
More information about the SciPy-user