Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hash(SparseVector) very slow #570

Open
dpinol opened this issue Oct 18, 2024 · 1 comment
Open

hash(SparseVector) very slow #570

dpinol opened this issue Oct 18, 2024 · 1 comment

Comments

@dpinol
Copy link
Contributor

dpinol commented Oct 18, 2024

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)
@fredrikekre
Copy link
Member

fredrikekre commented Oct 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants