Robert wrote:
> How to deal with Python's array.array directly - as with numpy.pxd 
> is there a array.pxd ?

Which Python version?

Under Python 3 this should probably happen automatically, try:

cdef object[int, ndim=1, mode="c"] arr = yourarray

Not sure about Python 2.6+

For Python 2.5- an array.pxd must be written. It is not difficult, one 
simply follows the pattern in numpy.pxd (by implementing __getbuffer__ 
and filling in the Py_buffer struct).

If somebody ends up doing this, please submit it for inclusion in 
Python. Here's some docs:

http://wiki.cython.org/docs/specialmethods
http://wiki.cython.org/enhancements/buffer
http://docs.python.org/c-api/buffer.html

> Similar Question regarding a good way of using PIL images directly 
> (without copying) ? Are there examples?

I don't think so. I believe the story is the same (one must make an 
Image.pxd implementing __getbuffer__ on the behalf of PIL). However IIRC 
the "full" mode must be used (i.e. images are stored as arrays of 
pointers to arrays), so it is slightly more complicated to get the 
details rest.

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to