[Cython] buffer bug
mark florisson
markflorisson88 at gmail.com
Sun Oct 2 13:13:05 CEST 2011
On 2 October 2011 12:04, Dag Sverre Seljebotn
<d.s.seljebotn at astro.uio.no> wrote:
> 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?
Ah, perhaps they are, but I didn't get any error message.
>> 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.
Right, readonly memoryviews, I think the current buffer support
supports not asking for a buffer with PyBUF_WRITABLE (when there is no
item assignment in that function). Memoryviews cannot make the same
assumption because they can be passed anywhere without requesting a
new buffer, so they always insert PyBUF_WRITABLE in the flags when
requesting the buffer.
>> 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
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>
Ok, sounds good. Let's see what happens, I'm probably going to be
quite busy, but the weather forecast also mentioned rain... :)
More information about the cython-devel
mailing list