setup6 = setup + """
from scipy import sparse
class Sparsemat(sparse.coo_matrix):
    def __iadd__(self, other):
        self.data += other.data
        return self
A = Sparsemat(sparse.rand(dim, dim, 0.5, 'coo')) 
D = np.random.random((dim, dim)) 
anz = A.nonzero()
"""
stmt6 = """
DS = Sparsemat((D[anz[0],anz[1]], anz), shape=A.shape) 
A += DS
"""
print('sparse2 ' + str(timeit.timeit(stmt6, setup6, number=3)))
Numpy arrays with mixed mutable and immutable values