Skip to content

hashing of ranges is awful #5778

Closed
Closed

Description

julia> @which hash(1:10)
hash(a::AbstractArray{T,N}) at dict.jl:247

The first issue is that this is incredibly slow:

julia/base/dict.jl

Lines 246 to 252 in 72a65be

function hash(a::AbstractArray)
h::Uint = hash(size(a))+1
for i=1:length(a)
h = bitmix(h,int(hash(a[i])))
end
return h
end

It's unclear to me why we're using indexing here instead of just iterating, but the code if very old so maybe it made sense at the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    breakingThis change will break codeperformanceMust go faster

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions