JuliaLang/julia

add fast path for very small Dicts?

Open

#10,907 建立於 2015年4月20日

在 GitHub 查看
 (22 留言) (0 反應) (0 負責人)Julia (48,709 star) (5,773 fork)batch import
help wantedperformancespeculative

描述

Was at first surprised that unique doesn't filter custom types even if they evaluate to equal by == but the helpdoc does say they should be equivalent and \equiv evaluates to is, however have noticed several times on both 0.3 and 0.4 that functions filling up an array with objects created through permutations and then return unique(result) will produce an array of variable length from a deterministic algorithm. The most recent encounter was with findpows (in this commit) before unique was replaced with uniquefilter. Have not had the handpower to unwrap a case into a neat isolated example and would not have opened this if not for the following unearthed feature of uniquefilter{T}(a::Array{T})=pushallunique!(T[],a):

julia> r=rand(Int,1000000)%3;

julia> @time for i in 1:1000;unique(r);end
elapsed time: 23.492532326 seconds (560000 bytes allocated)

julia> @time for i in 1:1000;Equations.uniquefilter(r);end
elapsed time: 11.805153784 seconds (160000 bytes allocated)

貢獻者指南