Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eval can be replaced by getfield in select #322

Open
julbinb opened this issue Dec 1, 2020 · 2 comments
Open

Eval can be replaced by getfield in select #322

julbinb opened this issue Dec 1, 2020 · 2 comments
Milestone

Comments

@julbinb
Copy link

julbinb commented Dec 1, 2020

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

prev = :( merge($prev, QueryOperators.NamedTupleUtilities.oftype(_, Val($(eval(Symbol(m_type[1])))))) )

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
Copy link
Member

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.

@davidanthoff davidanthoff added this to the Backlog milestone Jan 6, 2021
@julbinb
Copy link
Author

julbinb commented Jan 6, 2021

Sure :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants