-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Using cachedmethod with key=partial(hashkey, 'pep') is wrong #326
Comments
You're right, with >>> print(list(docs.cache.keys()))
[('pep', <__main__.CachedReferences object at 0x7f5f2bbcead0>, 1), ('rfc', <__main__.CachedReferences object at 0x7f5f2bbcead0>, 1)] However, AFAICS the behavior is as intended and not generally wrong, just a little less efficient than it could be. |
@tkem thank you for the reply. The main problem is the inconsistency between this and the first example in the docs where When using So when the inconsistency is the first problem, the second problem is the lack of an example of how to use |
@NoamNol Thanks for your response! |
One simple solution would be to use a keyword argument to differentiate, i.e.
This would lead to the following keys, where the
|
In the docs there is this example with
key=partial(hashkey, 'pep')
:I think it's wrong to use
partial(hashkey, 'pep')
withcachedmethod
, because theself
argument is passed to thekey
function.Usually
self
is ignored by the defaultmethodkey
function, but withpartial(hashkey, 'pep')
it's not ignored.Also we can't replace it with
key=partial(methodkey, 'pep')
because'pep'
will be the ignored argument instead ofself
.The text was updated successfully, but these errors were encountered: