[Numpy-discussion] PyArray_BASE equivalent in python
Peter Rennert
p.rennert at cs.ucl.ac.uk
Tue Nov 26 14:54:36 EST 2013
Hi,
I as the title says, I am looking for a way to set in python the base of
an ndarray to an object.
Use case is porting qimage2ndarray to PySide where I want to do
something like:
In [1]: from PySide import QtGui
In [2]: image =
QtGui.QImage('/home/peter/code/pyTools/sandbox/images/faceDemo.jpg')
In [3]: import numpy as np
In [4]: a = np.frombuffer(image.bits())
--> I would like to do something like:
In [5]: a.base = image
--> to avoid situations such as:
In [6]: del image
In [7]: a
Segmentation fault (core dumped)
The current implementation of qimage2ndarray uses a C function to do
PyArray_BASE(sipRes) = image;
Py_INCREF(image);
But I want to avoid having to install compilers, headers etc on target
machines of my code just for these two lines of code.
Thanks,
P
More information about the NumPy-Discussion
mailing list