[pythran] Re: ndarray

  • From: Mehdi Amini <mehdi.amini@xxxxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Sat, 30 Aug 2014 20:25:38 -0700


I'm unsure how we can produce efficient code for a function that would accept both a dense array and a strided one. It means that it should either be expressed in the interface (pythran export ....), or disallowed.


On 8/29/14, 3:32 PM, Neal Becker wrote:
Silently producing wrong results is a bad thing

with ndarray, the c++ code can specify the minimum # contiguous dimensions it will accept. If it expects a dense array, for example,
and is passed an array that is not contiguous,

then boost::python will complain about being unable to convert. Not a very good error message, but at least you get a message.

You could even put 2 versions of your routine (or for that matter, M versions) - such as one that accepts only dense arrays and another that works for general strides.

At a minimum, an error message should be produced at runtime.

The best behavior would be for pythran to handle both strided and non-strided arrays correctly, and as efficiently as possible. But I have no idea how difficult that would be.

On Fri, Aug 29, 2014 at 4:50 PM, serge Guelton <sguelton@xxxxxxxxxxxxx <mailto:sguelton@xxxxxxxxxxxxx>> wrote:

    > Just for information. On your example:
    > #export sum(int[])
    > def sum (x):
    > We will *assum* that x is contiguous.
    > If you use : sum(a[::2]), you will have an incorrect output.
    > It can be fix if you need this kind of use.

    Correct. We should open a ticket on this one...

/Those who don't understand recursion are doomed to repeat it/

Other related posts: