The median filter in scipy.signal is not optimal. Following
discussion, there are much faster implementations, even in pure python. However, the fastest method
running_median_insort, is not a drop-in replacement for
scipy.signal.medfilt as it does not calculate the central median but the
right sided median. However, by zero-padding as in the code below the behavior of the
scipy implementation is exactly reproduced.
Applying the filter with width 1023 on an example of some 2^15+1 data samples takes 50.3 ms on my laptop, compared to 2.65s for the medfilter in scipy v0.18 while there is no difference between the results.