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

make it easier to use statically typed containers #25

Open
mhinsch opened this issue Feb 21, 2023 · 0 comments
Open

make it easier to use statically typed containers #25

mhinsch opened this issue Feb 21, 2023 · 0 comments

Comments

@mhinsch
Copy link

mhinsch commented Feb 21, 2023

As it is now the cache generated by @memoize will always by of type Any => Any which can be sub-optimal. If argument and return types of the memoized function are known (and known to not change) it would be nice if the user could provide a fully typed container type for the cache.

However, since @memoize internally keeps function arguments in a tuple of two tuples (one for positional and one for named arguments), key types are a bit inconvenient. A function with a single Int argument for example produces Tuple{Tuple{Int64}, Tuple{}} as a key type for the internal cache.

If there is no simple way to sanitize the key type it would be useful to at least have a function that maps argument types of a function to the key type used by the macro, so that this for example would work:

@memoize Dict{memo_key_type(Int, Float64), String} function my_fun(x, y)
    "bla"
end
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

1 participant