Stefan Behnel wrote:
> Tuples support '+' and '*'. My immediate intuition is that an array type
> should behave exactly like a (mutable, but fixed-size) tuple, except where
> C dictates otherwise.
>
>   
>> I'm convinced that + would be used *a lot* more for componentwise
>> addition than for concatenation.
>>     
>
> I agree - at least in numerics. But if you want a mathematical vector type,
> that's a different thing than a memory managed C array IMHO.
>
> BTW, didn't we have this discussion twice already? That shows that at least
> my intuition keeps clearly dictating otherwise, each time we get here.
>   
Hmm, don't remember previous discussions. Anyway there's not that much 
to *discuss* as such; there's obvious interests at conflict here and the 
case seems clear for both.

I'll try to put down the interesting points:

1) Concatenation is a slow operation with large overhead where one can 
after all just use Python objects or cdef methods with negligble 
overhead. Addition is a real usecase where Cython can provide something 
Python/NumPy can not provide (by reducing memory bus traffic for large 
expressions). I.e. concatenation can be done without this feature, while 
for efficient expression evaluation one would have to switch to another 
language -- there's NO way of getting it in Cython otherwise.

2) I'd have to reconsider how much work I'm willing to put into this 
given concatenation semantics. I am scratching my own itch here. If + is 
chosen for concatenation I might end up having to use Fortran anyway in 
some cases (where Python/NumPy isn't fast enough), and so my motivation 
would be mainly on getting Kurt's GSoC through rather than empower 
Cython in general in this area.

3) Sometimes no feature at all is much better than a wrong or 
unintuitive feature, so 2) should NOT decide this, and I'll deal just 
fine with a "no" nevertheless :-)

4) Looking at mailing list activity, the numerical crowd is a very 
significant user of Cython

5) But again, the numerical stuff has happened as a byproduct, I realize 
that neither you nor Robert need it, and that Cython's real goal lies 
elsewhere


Trying one last time for constructive solutions though:
- There's always compiler directives
- Or int[:,:,componentwise=True]

OTOH, clearly

rsq = add(mul(x, x), mul(y, y))

is rather out of the question :-)

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

Reply via email to