scipy/scipy — pull request #3582 by jnothman (2014-04-26 15:13:11+00:00)
Title: Sparse: faster CSR/CSC setitem with change in sparsity

Given @pv's comment at https://github.com/scipy/scipy/issues/3501#issuecomment-41467146, here's a faster change-in-sparsity path for CSR/CSC `__setitem__`.

Master:
```
Sparse Matrix fancy __setitem__
==========================================================
N | s.patt. | csr | csc | lil | dok |
----------------------------------------------------------
1 | change | 0.80ms | 0.67ms | 0.01ms | 0.01ms
1 | same | 0.16ms | 0.15ms | 0.01ms | 0.01ms
10 | change | 0.87ms | 0.82ms | 0.20ms | 0.15ms
10 | same | 0.17ms | 0.16ms | 0.12ms | 0.15ms
100 | change | 3.50ms | 3.89ms | 0.11ms | 0.21ms
100 | same | 0.17ms | 0.16ms | 0.14ms | 0.20ms
1000 | change | 21.00ms | 22.00ms | 0.45ms | n/a
1000 | same | 0.21ms | 0.22ms | 0.25ms | n/a
10000 | change | 38.33ms | 38.33ms | 1.92ms | n/a
10000 | same | 0.84ms | 0.89ms | 2.04ms | n/a
```

This PR
```
Sparse Matrix fancy __setitem__
==========================================================
N | s.patt. | csr | csc | lil | dok |
----------------------------------------------------------
1 | change | 1.09ms | 1.05ms | 0.03ms | 0.03ms
1 | same | 0.16ms | 0.65ms | 0.01ms | 0.01ms
10 | change | 0.70ms | 0.59ms | 0.16ms | 0.17ms
10 | same | 0.16ms | 0.68ms | 0.12ms | 0.15ms
100 | change | 0.79ms | 0.76ms | 0.16ms | 0.19ms
100 | same | 0.17ms | 0.68ms | 0.13ms | 0.21ms
1000 | change | 0.78ms | 0.78ms | 0.29ms | n/a
1000 | same | 0.23ms | 0.84ms | 0.24ms | n/a
10000 | change | 1.62ms | 1.94ms | 2.30ms | n/a
10000 | same | 0.85ms | 2.13ms | 2.02ms | n/a
```