[Cython] buffer bug

Dag Sverre Seljebotn d.s.seljebotn at astro.uio.no
Sun Oct 2 13:04:26 CEST 2011


On 10/02/2011 12:38 PM, mark florisson wrote:
> Hey,
>
> I'm unable to login in trac, but I found a bug in the buffer support:
>
> cimport cython
> cimport numpy as np
>
> @cython.boundscheck(False)
> @cython.wraparound(False)
> cdef void func(np.ndarray[np.float32_t, ndim=2] a) nogil:
>      pass
>
> This calls __Pyx_GetBufferAndValidate, which needs the GIL.

Hmm. I thought buffers were disallowed as arguments to cdef functions?

> When I get the last failing tests fixed (introduced after rebasing on
> the latest master) for memoryviews, should be transform the current
> buffer support to memoryviews before doing a release? The only
> incompatibility I see is that readonly buffers are not supported.

Do you mean readonly memoryviews?

I'm not sure how much of an issue it is. NumPy arrays support being 
readonly, but it is not straightforward to make a NumPy array so.

Eventually I guess "const int[:]" should be supported; one could do so 
even without allowing const anywhere else.

> On the other hand it might be a good idea to wait with that, in case
> there are any bugs. We don't want to break everyone's existing code.
> Opinions?

I think this is mostly a question of how much time you have to work on 
it. Transforming buffer support into memoryviews would be a new feature 
branch, and whether that branch is merged into next release depends on 
the timing for the next release I'd say. I don't think a new release has 
to happen in the meantime, if you want to make it before, all the better!

Dag Sverre


More information about the cython-devel mailing list