[Numpy-discussion] Quicker image transfer, tobuffer?

Travis Oliphant oliphant at ee.byu.edu
Tue Jul 11 17:02:14 CDT 2006

Filip Wasilewski wrote:

>Hi Travis,
>this is a great example of the __array_interface__ usage.
>The second seems to be more complex and may be a more general. The
>memory of string created by self.tostring() seems to be deallocated
>before array is created (v, win).
>Everything works fine after storing the reference to data, but this
>probably should be done somewhere else:
>     def __get_array_interface__(self):
>         new = {}
>         shape, typestr = _conv_type_shape(self)
>         new['shape'] = shape
>         new['typestr'] = typestr
>         new['data'] = self.tostring()
>         self._str_data = new['data']    # a dirty hack
>         return new
This is now fixed in NumPy.  The problem was that when the "buffer" 
interface was used a reference to the object was kept (but not the 
buffer).  In this case it's the reference to the buffer that is needed.


More information about the Numpy-discussion mailing list