On Wed, Jul 14, 2010 at 10:47 PM, Robert Bradshaw
<[email protected]> wrote:
> On Wed, Jul 14, 2010 at 7:47 PM, Carl Witty <[email protected]> wrote:
>> On Wed, Jul 14, 2010 at 6:59 PM, Robert Bradshaw
>> <[email protected]> wrote:
>>>> In my experience, I always have to resort to Fortran or C++. Cython cannot
>>>> use NumPy arrays efficiently as function arguments. That is a big show 
>>>> stopper.
>>>
>>> Could you clarify? I suppose for very small arrays, there's the extra
>>> O(1) type-check/stride extraction overhead. Is there anything else? Of
>>> course there's always more room for improvement for the array type.
>>
>> Sometimes I write functions that don't iterate over every element of
>> their argument arrays :)
>
> Good point. How does Fortran handle this better? Does it just know
> that the strides are not aliased? (Or, does it know dimensions/other
> data at compile time.)

You can do the following in Fortran 90 (if this is what Carl was referring to):

do i = 1, n
    lharr(i, :) = m * rharr(i, :) + b
enddo

Where 'm' and 'b' can be scalars or 1D arrays of the proper length.
Think numpy-arrays-lite, including simple broadcasting rules and array
expressions, and much faster.

Kurt
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to