mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
bpo-38006: Avoid closure in weakref.WeakValueDictionary (GH-15641)
weakref.WeakValueDictionary defines a local remove() function used as callback for weak references. This function was created with a closure. Modify the implementation to avoid the closure.
This commit is contained in:
parent
b3b48c81f0
commit
a2af05a0d3
3 changed files with 10 additions and 2 deletions
|
@ -108,12 +108,12 @@ class WeakValueDictionary(_collections_abc.MutableMapping):
|
|||
else:
|
||||
# Atomic removal is necessary since this function
|
||||
# can be called asynchronously by the GC
|
||||
_atomic_removal(d, wr.key)
|
||||
_atomic_removal(self.data, wr.key)
|
||||
self._remove = remove
|
||||
# A list of keys to be removed
|
||||
self._pending_removals = []
|
||||
self._iterating = set()
|
||||
self.data = d = {}
|
||||
self.data = {}
|
||||
self.update(other, **kw)
|
||||
|
||||
def _commit_removals(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue