Stefan Behnel wrote:
> Hi,
> 
> Dag Sverre Seljebotn wrote:
>> cdef ndarray[int, 2D]
>>
>> - Require that ndim is given by name. The verbosity of this is a big 
>> problem IMO.
> 
> One of the two, not both. FWIW, I'm +0 on the keyword argument.
> 
> There's also the question regarding the brackets: [] or (). Wouldn't
> 
>     ndarray(int, ndim=2)
> 
> match the proposed assumption syntax?

The proposed assumption syntax and the proposed buffer syntax has been 
the same thing pretty much, as both were motivated from the usecase first.

Using () for buffers were considered and we ruled it out because it 
seems like a constructor (which has different arguments):

cdef ndarray(int, 2) buf = ndarray([1, 2, 3, 4], dtype=int)

Also () is used in a lot of places already.

<> is another option, but it is already used for casts (and potentially 
C++ templates). Still I'm starting to lean towards <> as a solution for 
this as well.

Pex uses {}. I might be wrong in this, but it just looks too ugly, and 
for some reason looks more like a dict than [] looks like a list (I 
suppose because [] is already overloaded for doing indexing).

Actually I'm not sure how big the problem is -- there's never any real 
need for the int[] syntax, you usually do "int varname[43]" or "int*" or 
34*sizeof(int) instead. You still have to "know" for other the other 
syntax proposals that the number is the ndim and not length... but 
perhaps [] contribute to that problem...

More:
buffer(ndarray, int, 2)
ndarray.buffer(int, 2)

Both less transparent and harder to use...

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to