JuliaLang/julia

`allunique(::String)` performance anomaly

Open

#50 360 ouverte le 29 juin 2023

Voir sur GitHub
 (17 commentaires) (0 réactions) (0 assignés)Julia (5 773 forks)batch import
good first issueperformancestrings

Métriques du dépôt

Stars
 (48 709 stars)
Métriques de merge PR
 (Merge moyen 20j 6h) (157 PRs mergées en 30 j)

Description

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

Guide contributeur