JuliaLang/julia

`allunique(::String)` performance anomaly

Open

#50,360 opened on 2023年6月29日

GitHub で見る
 (17 comments) (0 reactions) (0 assignees)Julia (5,773 forks)batch import
good first issueperformancestrings

Repository metrics

Stars
 (48,709 stars)
PR merge metrics
 (平均マージ 20d 6h) (30d で 157 merged PRs)

説明

It seems that allunique is not short-circuiting efficiently for strings

julia> VERSION
v"1.10.0-DEV.1604"

julia> using Random

julia> using BenchmarkTools

julia> s=randstring(100000);

julia> @btime allunique(s)
  140.850 μs (7 allocations: 848 bytes)
false

julia> @btime allunique(s[1:100]) && allunique(s)
  575.746 ns (8 allocations: 968 bytes)
false

140 μs >> 575 ns

コントリビューターガイド