scipy/scipy — pull request #3248 by jnothman (2014-01-28 01:31:16+00:00)
Title: ENH much more efficient sparse min/max with axis

The current implementation of `min`, `max` for sparse matrices with a specified axis is very slow, and the use of `np.where(M.indices == col)` wastes both time and memory. I don't promise this to be the tightest replacement, but it certainly works much faster at scale!

```
side density @ master @ branch
length axis=0 axis=1 axis=0 axis=1
100 0.001 0.0232 0.0236 0.0011 0.0011
100 0.01 0.0238 0.0192 0.0033 0.0035
100 0.1 0.0162 0.0164 0.0050 0.0052
1000 0.001 0.1574 0.1590 0.0275 0.0216
1000 0.01 0.1858 0.1884 0.0281 0.0296
1000 0.1 0.4279 0.4298 0.0302 0.0313
10000 0.001 4.2201 4.2422 0.2791 0.2941
10000 0.01 27.7040 27.8543 0.2979 0.3353
10000 0.1 - - 0.5101 0.8341
```