[Numpy-discussion] Cython numerical syntax revisited

Anne Archibald peridot.faceted@gmail....
Fri Mar 6 12:45:57 CST 2009


2009/3/5 Francesc Alted <faltet@pytables.org>:
> 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...

Not necessarily. You can transform

a[1,2,3]

into

*(a.data + 1*a.strides[0] + 2*a.strides[1] + 3*a.strides[2])

without any need for static information beyond that a is
3-dimensional. This would already be valuable, though perhaps you'd
want to be able to declare that a particular dimension had stride 1 to
simplify things. You could then use this same implementation to add
automatic iteration.

Anne

>
> Cheers,
>
> --
> Francesc Alted
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the Numpy-discussion mailing list