[Cython] planning for 0.17

Stefan Behnel stefan_ml at behnel.de
Wed Jun 27 14:48:04 CEST 2012


mark florisson, 27.06.2012 14:17:
> On 27 June 2012 12:59, Stefan Behnel wrote:
>> mark florisson, 27.06.2012 11:54:
>>> I can't test it right now, but I don't understand the following in the
>>> release notes (regarding array.array): "Note that only the buffer
>>> syntax is supported for these arrays. To use memoryviews with them,
>>> use the buffer syntax to unpack the buffer first.". Why is that, it
>>> implements __getbuffer__ right? So it shouldn't matter whether you use
>>> memoryviews or buffer syntax, both use __Pyx_GetBuffer().
>>
>> The problem is that arrayarray.pxd is only used when the exporter is typed.
>> This means that you can't do this:
>>
>>    def func(int[:] arr): pass
>>
>>    func(array.array('i', [1,2,3]))
> 
> That works for me, as long and array is cimported from cpython (as
> 'array' or some other name). It will patch __Pyx_GetBuffer with a
> typecheck and a call to its __getbuffer__ method.

Hmm, interesting. I keep learning. I'll add tests for that.

For the memoryview_type and array_type checks, wouldn't a type identity
test be enough instead of a PyObject_TypeCheck() ?

Stefan


More information about the cython-devel mailing list