-
Notifications
You must be signed in to change notification settings - Fork 25
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
Steps towards more symbolic dict keys in memoize_on_first_arg, memoize_method #80
base: main
Are you sure you want to change the base?
Conversation
cache_dict_name = intern( | ||
f"_memoize_dic_{function.__module__}{function.__name__}" | ||
) | ||
cache_dict_name = (memoize_on_first_arg, function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work if function
is nested (i.e. not in the global namespace)? It should keep changing its hash/id in that case, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, nested functions are a difficult case, mainly because it's hard to get stable identifiers for them. My understanding is that, at least, it would fail "safe" (separate caches for each function) using this code.
IMO, @memoize_in
is more appropriate for nested functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a small note to the docs that it's really not recommended for nested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides that, it looks good to me! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I added loopy downstream CI because I happen to know that this change breaks loopy.) |
Huh, TIL it doesn't. scratches head All the better. :) |
Turns out the downstream CIs weren't actually using this code:
|
There we go. :) Downstream CI is not such a bad thing... when it works. |
No description provided.