But you are returning a list, not a SparseMatrix as before.  Also, previously the maximum number of elements to look at is self.cols but now you are looking at all elements in the sparse matrix. Why not just iterate over whichever is smaller?