[ANN] ShowLint

My thinking was that this would save allocating an array here. Although for findall in particular, it might not actually be faster?

julia> @btime findfirst(x->!x, r) setup=(r=rand(Bool, 10^6)); # same as findfirst(!, r)
  2.283 ns (0 allocations: 0 bytes)

julia> @btime findfirst(.!r) setup=(r=rand(Bool, 10^6));
  137.891 μs (4 allocations: 126.42 KiB)

julia> @btime count(x->!x, r) setup=(r=rand(Bool, 10^6));
  80.810 μs (0 allocations: 0 bytes)

julia> @btime count(.!r) setup=(r=rand(Bool, 10^6));
  142.010 μs (4 allocations: 126.42 KiB)

julia> @btime findall(x->!x, r) setup=(r=rand(Bool, 10^6));
  671.744 μs (8 allocations: 3.92 MiB)

julia> @btime findall(.!r) setup=(r=rand(Bool, 10^6));
  668.053 μs (6 allocations: 3.93 MiB)

Edit – that’s because the second-last line explicitly calls the last here, findall(testf::Function, A::AbstractArray) = findall(testf.(A)), so there can’t be a difference. Sorry about the noise!

2 Likes

This is a good idea and I hope it can gain some more traction / incorporation into IDEs. Traceur.jl has a similar design space and is perhaps worth looking into.

1 Like

I think the author of comby did this against a large GitHub code-base and automatically submitted PRs

Also see: