On Tue, Jul 17, 2012 at 9:55 PM, Christian Heimes <li...@cheimes.de> wrote: > 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!
If you're worried about supporting older Python versions then the simplest thing is probably to just implement the __array_interface__ or __array_struct__ interface. They're pretty trivial, and while not as standards-compliant and Correct as PEP3118, they'll work just fine with numpy across any version of Python. (Of course you can also implement both PEP3118 and __array_struct__ together.) http://docs.scipy.org/doc/numpy/reference/arrays.interface.html -n _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel