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[:]

Also consider that "array" is already a Python builtin doing much of 
what Stefan seems to be after, at least Python side. array[int] should 
perhaps at least be an alias for what Stefan wants int[:] to be, at 
least in 1D, although Stefan's arguments from "expectation of random 
Python user" is still valid.

(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.)
-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to