Consider the following two functions:
function f1(t, a)
[t(x) for x in a]
end
function f2(t, a)
Dict((x, t(x)) for x in a)
end
When I run @code_warntype on them I get:
julia> @code_warntype f1(sin, [1.0, 2.0])
Variables:
#self#::#f1
t::Base.#sin
a::Array{Float64,1}
Body:
begin
What about storing eltypes in variables and directly calling
'Dict{eltypa,eltypet_a}(...)'? I think there is some issue about this github
too.
using FastAnonymous
INFO: Precompiling module FastAnonymous.
WARNING: symbol is deprecated, use Symbol instead.
in depwarn(::String, ::Symbol) at ./deprecated.jl:64
in symbol(::String, ::Vararg{String,N}) at ./deprecated.jl:30
in include_from_node1(::String) at ./loading.jl:488 (repeats 2 tim
Don't use it? Anonymous functions are fast in 0.5 now.
On Sunday, November 13, 2016, wrote:
> using FastAnonymous
>
> INFO: Precompiling module FastAnonymous.
> WARNING: symbol is deprecated, use Symbol instead.
> in depwarn(::String, ::Symbol) at ./deprecated.jl:64
> in symbol(::String, ::Var
Until the issue with generators is resolved, this may suffice:
f2x{T}(t::Function,a::AbstractArray{T})::Dict{T,T} = Dict((x,t(x)) for x in
a)
I think that diverts all the ambiguities to checks by conversion methods.
On Sunday, November 13, 2016 at 11:16:20 AM UTC-5, bogumil@gmail.com
wrot
Hello Tom
In fact, AF already exist in julia 0.5. Thanks for this ;)
Em domingo, 13 de novembro de 2016 16:59:46 UTC-2, Tom Breloff escreveu:
>
> Don't use it? Anonymous functions are fast in 0.5 now.
>
> On Sunday, November 13, 2016, >
> wrote:
>
>> using FastAnonymous
>>
>> INFO: Precompiling