Steps towards more symbolic dict keys in memoize_on_first_arg, memoize_method#80
Steps towards more symbolic dict keys in memoize_on_first_arg, memoize_method#80
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.
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.
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.
Maybe add a small note to the docs that it's really not recommended for nested?
There was a problem hiding this comment.
Besides that, it looks good to me! 👍
|
(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.