[Cython] 2d buffer interface with aligned data

Stefan Behnel stefan_ml at behnel.de
Wed Jul 18 07:18:34 CEST 2012


Christian Heimes, 17.07.2012 22:55:
> Am 17.07.2012 18:55, schrieb Dag Sverre Seljebotn:
>> Read PEP 3118. Then implement __getbuffer__ and __releasebuffer__ in
>> your cdef class (don't know if it's documented but you can see example
>> in tests/run/buffer.pyx).
> 
> The new buffer interface from PEP 3118 is only available for Python 2.6
> and newer. I was hoping for some abstraction layer in Cython. Well, I
> don't have to support Python 2.5 and older. Thanks for the hint!

Cython supports the buffer interface also in older Python versions as long
as you implement your buffer methods in a .pxd file as part of the
extension type declaration and cimport from that in the modules where you
use it. It's a pure Cython feature though, other extensions (and Python
code, obviously) won't see it.

BTW, note that your question is better suited for the Cython users mailing
list than the core developer mailing list.

Stefan


More information about the cython-devel mailing list