queryverse / Query.jl

Query almost anything in julia
Other
395 stars 50 forks source link

Eval can be replaced by getfield in select #322

Open julbinb opened 3 years ago

julbinb commented 3 years ago

getfield would be more efficient than eval in getting the value of a variable/type here:

https://github.com/queryverse/Query.jl/blob/a4c0ea1e18227d0495a5bd764e7fae4328a56113/src/table_query_macros.jl#L75

Toy example:

julia> using BenchmarkTools

julia> @btime getfield(Main, Symbol("Int"))
  0.015 ns (0 allocations: 0 bytes)
Int64

julia> @btime eval(Symbol("Int"))
  58.841 ns (0 allocations: 0 bytes)
Int64
davidanthoff commented 3 years ago

Yep, true :) Do you want to open a PR?

Probably doesn't make too much of a difference because it shouldn't really run in any kind of inner loop, but still would be nice to fix this.

julbinb commented 3 years ago

Sure :)