-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Performance issue on comparison between String
and SubString
#32401
Comments
The problem is reduced to:
The behavior is similar when the result is |
Nice reduction, @rfourquet. It's because of calling generic string julia> @which s1 == s1
==(a::AbstractString, b::AbstractString) in Base at strings/basic.jl:294
julia> @which s1 == s2
==(a::AbstractString, b::AbstractString) in Base at strings/basic.jl:294
julia> @which s2 == s2
==(a::String, b::String) in Base at strings/string.jl:105 I thought that @bkamins had fixed this at some point, but maybe I'm misremembering. |
The proposal was the following #26921 (+ see the discussion on pros and cons). When I am done with pressing DataFrames.jl fixes which need to be shipped before JuliaCon I think I can go back to that issue (of course feel free to overtake it if you prefer - thank you). |
I just posted this over there:
|
The performance difference seems to be fixed already. Tested on v1.7.2: str = "abcdefghi"
s1 = SubString(str, 4, 6) # "def"
s2 = "$(str[4:6])"
julia> @btime $s1 == $("def");
3.273 ns (0 allocations: 0 bytes)
julia> @btime $s2 == $("def");
3.776 ns (0 allocations: 0 bytes)
|
There is a performance issue when compare between
SubString
andString
. Here is an example to bring out this issue.The text was updated successfully, but these errors were encountered: