Repository metrics
- Stars
- (198 stars)
- PR merge metrics
- (Avg merge 11h 28m) (2 merged PRs in 30d)
Description
Right now, the @memoize macro creates the cache dictionary using eval:
https://github.com/JuliaCollections/Memoize.jl/blob/1709785afc1eed40d7d35e6c3ebe5ae7e076f57e/src/Memoize.jl#L49-L52
This is generally considered a bad idea in macros, and until recently, also caused an error here because the code was evaling into the Memoize package (see #32).
Right now, using eval gives the following behavior:
- all memoized methods of a given function share the memoization cache
- if a method is overwritten, the cache is cleared, and any other global resources created/held by the previous version of that method are released: https://github.com/JuliaCollections/Memoize.jl/blob/1709785afc1eed40d7d35e6c3ebe5ae7e076f57e/test/runtests.jl#L257-L266
I made one attempt to simply use a different cache dictionary for each method of a given function (https://github.com/JuliaCollections/Memoize.jl/compare/JuliaCollections:1709785...JuliaCollections:a9170e5). This mostly works, but as-is causes the test above to fail, because the old cache is not released when the method is overwritten.
There may be an easy way around this, but it's not obvious to me right now.
Thoughts and/or pull requests welcome!
Cc: @cstjean