[Numpy-discussion] A faster median (Wirth's method)
Robert Bradshaw
robertwb@math.washington....
Wed Sep 2 11:57:05 CDT 2009
On Wed, 2 Sep 2009, Dag Sverre Seljebotn wrote:
> 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?
>>
>> http://projects.scipy.org/numpy/attachment/ticket/1213/generate_qselect.py
>> http://projects.scipy.org/numpy/attachment/ticket/1213/quickselect.pyx
>>
> 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.
Danilo's C++ project has some baby steps in that direction, though it'll
need to be expanded quite a bit to handle this.
- Robert
More information about the NumPy-Discussion
mailing list