-
Notifications
You must be signed in to change notification settings - Fork 18
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
performance
#56
Comments
That's because these are calling the fallback hashing routine that converts to a We could add specialized hashing methods to LegacyStrings.jl, of course. It's not completely clear who is using this package, however, and whether its performance matters — it was mainly introduced for backwards compatibility when these types were kicked out of Base, but for most purposes we recommend using the built-in |
The idea of an I was actually going to suggest such a type be added to |
Can you give an example where O(1) See also myth 8.3 at utf8everywhere.org … we're quite aware of the instinctive desire for O(1) But maybe this isn't the best place to debate this. We've discussed the UTF-8 encoding and string indices ad nauseam on Julia discourse (e.g. see here), and it is also discussed in many places online e.g. utf8everywhere.org. |
I don't have a super compelling use case in mind, but the possibilities aren't limited by my ability to imagine them Anyways, I trust you've given this subject more thought than I have. I'm okay with closing this if you think it isn't worth the effort |
It would be easy to at least add fast hashing for function Base.hash(s::ASCIIString, h::UInt)
h += Base.memhash_seed
ccall(Base.memhash, UInt, (Ptr{UInt8}, Csize_t, UInt32), s, sizeof(s), h % UInt32) + h
end Fast hashing for the other legacy string types is harder because we want them to hash to the same value as |
Sounds good BTW, julia> @btime isequal(a,b)
17.790 μs (0 allocations: 0 bytes) # ::String
true
julia> @btime isequal(x,y)
1.333 ms (0 allocations: 0 bytes) # ::ASCIIString
true |
The text was updated successfully, but these errors were encountered: