[Numpy-discussion] Cython numerical syntax revisited
Dag Sverre Seljebotn
dagss@student.matnat.uio...
Thu Mar 5 04:33:52 CST 2009
Francesc Alted wrote:
> A Thursday 05 March 2009, Francesc Alted escrigué:
>
>> Well, I suppose that, provided that Cython could perform the for-loop
>> transformation, giving support for strided arrays would be relatively
>> trivial, and the performance would be similar than numexpr in this
>> case.
>>
>
> Mmh, perhaps not so trivial, because that implies that the stride of an
> array should be known in compilation time, and that would require a new
> qualifier when declaring the array. Tricky...
>
No, one could do the same thing that NumPy does (I think, never looked
into it in detail), i.e:
decide on dimension to do innermost dynamically from strides and sizes
save the stride in that dimension for each array
for loop using n-dimensional iterator with larger per-loop overhead:
save offsets
for loop on the innermost dimension with lower per-loop overhead:
component-wise operation using offsets and innermost strides
Dag Sverre
More information about the Numpy-discussion
mailing list