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

Efficient get_nargs #275

Open
gdalle opened this issue May 24, 2023 · 3 comments
Open

Efficient get_nargs #275

gdalle opened this issue May 24, 2023 · 3 comments

Comments

@gdalle
Copy link
Contributor

gdalle commented May 24, 2023

In a recent Discourse thread it surfaced that get_nargs takes up a sizeable part of the benchmark. The reason is that it allocates the whole methods table before considering the first element:

get_nargs(f) = first(methods(f)).nargs - 1

Besides it is not necessarily accurate if several methods have varying numbers of arguments. Any idea how we could overcome this?

@gdalle
Copy link
Contributor Author

gdalle commented May 24, 2023

The workaround I found for my package: JuliaDecisionFocusedLearning/ImplicitDifferentiation.jl#47

@dpo
Copy link
Member

dpo commented Jul 6, 2023

Sorry for the slow reply here. The obvious workaround would be for nargs to be an input to the constructor. Or we could have two constructors, LinearOperator and LinearOperator5 (say) for products with 5 arguments.

@geoffroyleconte What do you think?

@geoffroyleconte
Copy link
Member

Sorry for the slow reply here. The obvious workaround would be for nargs to be an input to the constructor. Or we could have two constructors, LinearOperator and LinearOperator5 (say) for products with 5 arguments.

@geoffroyleconte What do you think?

#282

Something like this?

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

No branches or pull requests

3 participants