-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
Signed-off-by: Kai A. Hiller <KaiAlexHiller@web.de>
Signed-off-by: Kai A. Hiller <KaiAlexHiller@web.de>
Signed-off-by: Kai A. Hiller <KaiAlexHiller@web.de>
yup, so this has been changed by python/cpython@ac20e0f#diff-8bd563e1946aef62abb51ecc6d162eaf. |
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.
thank you very much for the contribution!
This is in contrast to what was annotated in _CacheContext which claims that LruCache relies on the equality of _CacheContext objects itself.
well, it was kind of true, in that the equality of the invalidate
methods depended on the equality of the _CacheContext
objects, though I agree it wasn't very clear.
Anyway: I think this might be more intuitively solved by ensuring that we don't create duplicate _CacheContext
objects, so:
- leave
_CacheContext
as it was - create in
CacheDescriptor.__get__
, docache_contexts = {}
- at line 433, do
kwargs["cache_context"] = cache_contexts.setdefault(cache_key, _CacheContext(cache, cache_key))
wdyt?
Ensuring I'd argue that it's not CacheDescriptor's responsibility to manage caching of I think we still need to use a |
ok, that sounds reasonable.
I think you're right. I hadn't quite thought that part through! |
Signed-off-by: Kai A. Hiller <KaiAlexHiller@web.de>
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.
lgtm. I've merged latest develop
into the branch to try to get the CI to sort itself out.
🎉 |
thank you very much for contributing this and for working through the pain from the CI! |
FYI you didn't have to turn the function annotations into comments - that's valid Python 3 syntax. |
* commit 'affcc2cc3': Fix LruCache callback deduplication (#6213)
The PR fixes the deduplication issues for memoizing caches. It makes all identical _CacheContext objects share the same
invalidate
function. This is required for proper deduplication of invalidate callbacks in LruCache. LruCache is used for the@cached
function decorator. Fixes #6200.LruCache relies on the equality of callback functions for deduplication. This is in contrast to what was annotated in _CacheContext which claims that LruCache relies on the equality of _CacheContext objects itself.
Pull Request Checklist