[Cython] about to buffer syntax
Robert Bradshaw
robertwb at math.washington.edu
Fri Aug 22 10:13:23 CEST 2008
On Aug 11, 2008, at 8:42 AM, Lisandro Dalcin wrote:
> 2008/8/9 Dag Sverre Seljebotn <dagss at student.matnat.uio.no>:
>> My initial reaction is that I like it! However it might not be
>> needed...
>>
>> It would have to be (:n, :) rather than (n, :) for consistency.
>>
>> The thing is, you don't really need the shape in the syntax
>> currently, only ndim. (One can use an assert statement if one
>> wants the check, there doesn't appear to be any advantages to
>> knowing the shape compile-time, unless perhaps if it is very small.)
>>
>> however with this perhaps support for specifying a starting point
>> (index start point, subtracted on all lookups) could be added,
>> that would be potentially very useful but also tend to "add
>> cruft"...add something that is not there in either Python or C...
>
>> Time and users will have to tell! But I enjoyed such a fresh idea
>> in this discussion.
>
> Well, I believe that people with some background in Fortran 90 will
> definitely like and support my proposal.
>
>> I think one could make the ndim keyword mandatory at first, to
>> delay the decision about which positional argument should be 2nd.
>
> Well, I believe that is a good approach. IMHO, declaring
>
> cdef ndarray[int, 3] tmp
>
> is not really clear that '3' means a 3D array. The intention of my
> proposal is just to provide a syntax that is less ambiguous and have
> room for more facilities (shape checking, negative starts, require
> shape at least xD, etc.)
Your syntax is certainly more flexible. Given what we support, ndarray
[int, (:,:,:)] is a rather obscure way to declare a 3-dim array, but
if we add more features in the future this seems backwards compatible
with what we have now.
- Robert
More information about the Cython-dev
mailing list