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

Ability to turn off memoization for benchmarking #79

Open
lstagner opened this issue Nov 26, 2022 · 1 comment
Open

Ability to turn off memoization for benchmarking #79

lstagner opened this issue Nov 26, 2022 · 1 comment

Comments

@lstagner
Copy link

I've been benchmarking some code and it would be nice to be able to turn off memoization. Something like memoize!(false) which sets a global switch.

@cstjean
Copy link
Collaborator

cstjean commented Nov 26, 2022

If that can be done without a performance impact, then sure...

Note that you can already achieve the same thing on your side with:

use_memoize = true
struct OptionalMemoizer
    memo
end
haskey(om::OptionalMemoizer, key) = use_memoize ? haskey(om.memo, key) : false
...

and then use @memoize OptionalMemoizer(Dict() function ...

Another tack would be to run this interactively:

@eval Memoize macro memoize(fdef)
    esc(fdef)
end
Revise.revise(module_you_want_to_disable_memos)

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

2 participants