JuliaLang/julia

`allunique(::String)` performance anomaly

Open

#50,360 创建于 2023年6月29日

在 GitHub 查看
 (17 评论) (0 反应) (0 负责人)Julia (5,773 fork)batch import
good first issueperformancestrings

仓库指标

Star
 (48,709 star)
PR 合并指标
 (平均合并 20天 6小时) (30 天内合并 157 个 PR)

描述

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

贡献者指南