You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed two issues with documentation related to memoizing instance methods.
Consider the following case:
class MyClass:
@cache.memoize
def func(self, n):
return n
According to the documentation, I should provide a class object to the delete_memoized function when a classmethod is memoized. The documentation does not mention instance methods there, so this implies that it isn't necessary in such case.
However, this does not work as expected (the cache is not invalidated):
Another issue related to that is that it is not possible to invalidate all cached calls of a method by calling delete_memoized without any arguments. It works with regular functions, but it won't work with class/instance methods since they require at least one argument when calling delete_memoized. This behavior isn't documented either.
The text was updated successfully, but these errors were encountered:
I noticed two issues with documentation related to memoizing instance methods.
Consider the following case:
According to the documentation, I should provide a class object to the
delete_memoized
function when aclassmethod
is memoized. The documentation does not mention instance methods there, so this implies that it isn't necessary in such case.However, this does not work as expected (the cache is not invalidated):
Instead, one should do:
This isn't documented, however.
Another issue related to that is that it is not possible to invalidate all cached calls of a method by calling
delete_memoized
without any arguments. It works with regular functions, but it won't work with class/instance methods since they require at least one argument when callingdelete_memoized
. This behavior isn't documented either.The text was updated successfully, but these errors were encountered: