[Cython] Buffer type specification (CEP 514) in @cython.locals() in .pxd

Matěj Laitl matej at laitl.cz
Wed May 11 22:27:30 CEST 2011


Hi list,
it has been unusually quiet here so it's time to speak up.

How hard would it be to implement support for specifying buffer dtype (and 
friends) in @cython.locals() in a .pxd file? Following code (in a .pxd file)

cimport numpy
@cython.locals(local1 = numpy.ndarray[double])
cdef double f()

currently yields "test.pxd:4:32: Not a type" error. The problem is that one 
currently cannot make use of buffer access optimisation for local variables in 
pure python mode. I use pure mode extensively in my project [1].

[1] https://github.com/strohel/PyBayes

I understand that it has no sense in .py files as type type is not usually 
subscriptable.

On the same note, is there a plan to implement fast buffer access for class 
variables? ;) (this is obviously not that crucial)

Regards and keep up the good work!
   Matěj Laitl


More information about the cython-devel mailing list