SparseArrays.jl
SparseArrays.jl copied to clipboard
hash(SparseVector) very slow
const sp=spzeros(Int,1_000_000_000)
1000000000-element SparseVector{Int64, Int64} with 0 stored entries
@btime hash(sp)
182.608 ms (0 allocations: 0 bytes)
I can create a PR with the alternative implementation if you agree with it
@btime hash((sp.nzind, sp.nzval, sp.n))
4.208 ns (0 allocations: 0 bytes)
Needs to satisfy these properties I think:
julia> using SparseArrays
julia> x = zeros(5); xs = spzeros(5);
julia> isequal(x, xs)
true
julia> hash(x) == hash(xs)
true