Closed julbinb closed 8 months ago
getfield would be more efficient than eval in getting the value of a variable/function name here:
getfield
eval
https://github.com/JuliaText/TextAnalysis.jl/blob/dd67dcff6fe5444a4cbe9f244961cb97ff9c4a65/src/tagging_schemes.jl#L50-L51
Toy example:
julia> using BenchmarkTools julia> foo = 42 42 julia> @btime eval(Symbol("foo")) 44.230 ns (0 allocations: 0 bytes) 42 julia> @btime getfield(Main, Symbol("foo")) 1.180 ns (0 allocations: 0 bytes) 42
Thanks, yes, this code if probably from before getfield existed. I'd be grateful for a PR.
Ok, will do :)
fixed in https://github.com/JuliaText/TextAnalysis.jl/pull/276/commits/57781294ab34136ee67eba0abb5e6c9b1a0fb733
getfield
would be more efficient thaneval
in getting the value of a variable/function name here:https://github.com/JuliaText/TextAnalysis.jl/blob/dd67dcff6fe5444a4cbe9f244961cb97ff9c4a65/src/tagging_schemes.jl#L50-L51
Toy example: