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
{{ message }}
Repository navigation
Restore weakref support for lru_cache wrappers #84684
The pure python version of lru_cache() wrappers supported weak references. It's not essential, but I have used it a couple of times. In the spirit of PEP-399, the C version should add back the weakref support (and a test).
Activity
rhettinger commentedon May 4, 2020
The pure python version of lru_cache() wrappers supported weak references. It's not essential, but I have used it a couple of times. In the spirit of PEP-399, the C version should add back the weakref support (and a test).
sweeneyde commentedon May 4, 2020
I can submit a PR. Just making sure I understand, is this essentially the desired behavior change?
# Current:
# TypeError: cannot create weak reference to 'functools._lru_cache_wrapper' object
# Desired:
# <weakref at 0x000001ABFE0F5090; to 'function' at 0x000001ABFE2D5AF0 (f)>
rhettinger commentedon May 5, 2020
Yes. That is the desired behavior. Use Objects/setobject.c and Include/setobject.h as a model.
rhettinger commentedon May 5, 2020
New changeset 1253c3e by Dennis Sweeney in branch 'master':
bpo-40504: Allow weakrefs to lru_cache objects (GH-19938)
1253c3e
rhettinger commentedon May 5, 2020
Thanks for the PE :-)