function getIJValues(A::SparseMatrixCSC)
    m,n = size(A)
    rowcoords = rowvals(A)
    coordinates = []
    for j = 1:n
        append!(coordinates, [(rowcoords[i],j) for i in nzrange(A,j)])
    end
    return sort(coordinates)
end


I've never formally studied any computer science or programming so I don't 
have a great grasp on what goes on underneath this, but it seems to me like 
the only thing the garbage collector should need to do would be free the 
memory taken up by the list comprehension inside the loop at the end of the 
loop. And perhaps this could be redone in a more efficient manner, but 
inlining it like that seemed most natural. But what's strange is that 
called twice in a row, with exactly the same input, it takes twice as long 
the second time as the first.

Otherwise, I certainly wouldn't be surprised if this method is inherently 
inefficient, since I only picked up the language yesterday.

-- Sean

Reply via email to