[Cython] More array/buffer syntax
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Wed Aug 6 11:27:49 CEST 2008
Robert Bradshaw wrote:
> On Aug 4, 2008, at 6:18 PM, Greg Ewing wrote:
>
>> Dag Sverre Seljebotn wrote:
>>
>>> I don't think the [] syntax buys anything above a regular
>>> pointer notation? If so, removing support for int[]-notation
>>> altogether
>>> would get rid of the issue and lead to a cleaner grammar.
>> The current declaration syntax has the advantage that it's
>> the same as in C, so people familiar with C don't have to
>> learn anything new. This would be a step away from that,
>> although a fairly minor one.
>>
>> Another consideration is how much existing code it would
>> break, which could be quite a lot.
>
> +1
>
> Also, c_type[] vs. object_type[] are easily discerned, and they both
> have similar (high level) meaning.
Well, there is an assymetry. If you did
cdef int[handler=ndarray, ndim=2]
or
cdef int[ndarray, 2]
you would be more correct. Hey...Perhaps that is not such a bad idea?
Putting the dtype on the outside and the container type on the inside?
This would mimic C in some way.
One could have
cdef int[ndim=2, mode='full']
would be an int buffer on an object. And
cdef int[len=44, mode='native']
would mean the C int[44]...
Just brainstorming though.
--
Dag Sverre
More information about the Cython-dev
mailing list