Dag Sverre Seljebotn wrote:
> Stefan Behnel wrote:
>> Dag Sverre Seljebotn wrote:
>>> Anyway, thanks for clarifying the terms. So the question turns into: Is 
>>> it possible to add a *vector* type to Cython? Or is that pulling it too 
>>> far? (Choice of syntax aside.)
>> I'm for having both. The vector type could become a subtype of an array
>> that overrides the numeric operations (although I wouldn't care too much if
>> that's too hard to implement).
>>
>> We discussed the templating syntax a while ago. Even if that isn't there
>> yet, that doesn't mean we can't use its syntax.
>>
>>      from cython cimport Vector
>>      cdef Vector[int] some_vector
>>
>> would be the same as the equivalent "int[:]" array, except for arithmetic.
> 
> That answers most of my worries. I'll leave this to sink in for a few 
> days; but I'll start brainstorming for shorter syntax alternatives which 
> might make this discussion shorter :-)
> 
> Here's some starting points you all won't like:
> 
> int[:].cwise
> int.cwise[:]

Yes, you're right. :)

Honestly, what's so bad about making the vector type explicit? Even

        Vector[int[:]]
or
        Vector(int[:])

are better than a hard to read "cwise".


> Also consider that "array" is already a Python builtin doing much of 
> what Stefan seems to be after, at least Python side.

Well, yes, except for storing pointers and structs.


> (BTW, this is how a 2D arrays look in Fortran, which is still a very 
> dominant tool in numerics:
> 
> real, dimension(:,:) :: arr
> 
> So you can see where my inspiration with the [:] came from.)

I like the "int[:]" syntax. I just think that a vector should look
different in the code.

Stefan
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to