On Aug 5, 2008, at 12:20 PM, Dag Sverre Seljebotn wrote:

> 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.

My thoughts as well.

> <> 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.

I'm not a huge fan of this one, but it's certainly better than most  
options.

> 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).

Same here.

> 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...

I would like to see something like int[n] be useable to create  
automatically memory managed arrays of ints in the future. (Having to  
learn malloc, etc. seems to be one of the most un-pythonic thing of  
using Cython).

> More:
> buffer(ndarray, int, 2)
> ndarray.buffer(int, 2)
>
> Both less transparent and harder to use...

Yes, -1.


I think the best option is to use the D suffix. I'm not too worried  
about future compatibility with a decimal literal (if something like  
that ever comes), 'cause it wouldn't impose backwards incompatibility  
anyways.

- Robert

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

Reply via email to