[Numpy-discussion] A faster median (Wirth's method)
Dag Sverre Seljebotn
Wed Sep 2 07:53:20 CDT 2009
Sturla Molden wrote:
> Dag Sverre Seljebotn skrev:
>> Nitpick: This will fail on large arrays. I guess numpy.npy_intp is the
>> right type to use in this case?
> By the way, here is a more polished version, does it look ok?
I didn't look at the algorithm, but the types look OK (except for the
gil as you say). Comments:
a) Is the cast to numpy.npy_intp really needed? I'm pretty sure shape is
defined as numpy.npy_intp*.
b) If you want higher performance with contiguous arrays (which occur a
lot as inplace=False is default I guess) you can do
np.ndarray[T, ndim=1, mode="c"]
to tell the compiler the array is contiguous. That doubles the number of
function instances though...
> Cython needs something like Java's generics by the way :-)
Yes, we all long for that. It will come as soon as somebody volunteers I
suppose -- it shouldn't be all that difficult, but I don't think any of
the existing devs will be up for it any time soon.
More information about the NumPy-Discussion