[Cython] about to buffer syntax
Lisandro Dalcin
dalcinl at gmail.com
Mon Aug 11 17:42:55 CEST 2008
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.)
> -----Original Message-----
> From: "Lisandro Dalcin" <dalcinl at gmail.com>
> Date: Thursday, Aug 7, 2008 5:49 pm
> Subject: [Cython] about to buffer syntax
> To: Cython-dev <cython-dev at codespeak.net>Reply-To: cython-dev at codespeak.net
>
> I'm still convinced that Fortran 90 array declarators could provide a
>>more powerfull syntax for buffers, For this, the dimensions should be
>>specified with a tuple, examples below:
>>
>>cdef ndarray[int, ()] a # a scalar
>>
>>cdef ndarray[int, (3,)] # a1D array with 3 items
>>
>>cdef ndarray[int, (:,)] # a 1D array of any size
>>
>>cdef ndarray[int (2,3)] # 2D array with 2 rows and 3 columns
>>
>>cdef ndarray[int (:,3)] # 2D array with any number of rows and 3 columns
>>
>>cdef ndarray[int (:,:)] # 2D array with any number of rows and columns
>>
>>cdef ndarray[float, (3,3,:)] # 3D array, a 'sequence' of 3x3 array
>>
>>
>>We could even use Ellipsis '...' in a similar sense numpy uses them
>>
>>cdef ndarray[int, (...)] # any number of dimension
>>
>>cdef ndarray[int, (:, ...)] # at least 1D
>>
>>cdef ndarray[int, (:, : ,...)] # at least 3D
>>
>>cdef ndarray[int, (3, 5, ...)] # at least 2D, but required shape in
>>first two dims.
>>
>>
>>What do you think?
>>
>>
>>--
>>Lisandro Dalcín
>>---------------
>>Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
>>Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
>>Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
>>PTLC - Güemes 3450, (3000) Santa Fe, Argentina
>>Tel/Fax: +54-(0)342-451.1594
>>_______________________________________________
>>Cython-dev mailing list
>>Cython-dev at codespeak.net
>>http://codespeak.net/mailman/listinfo/cython-dev
>>
>
>
> _______________________________________________
> Cython-dev mailing list
> Cython-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/cython-dev
>
>
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
More information about the Cython-dev
mailing list