Skip to content
Merged
Prev Previous commit
Next Next commit
cache _atomic_removal in WeakValueDictionary._commit_removals
  • Loading branch information
graingert committed Aug 28, 2021
commit aada0e4a9bf51e956258a9a882eebc003e23c3d3
4 changes: 2 additions & 2 deletions Lib/weakref.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
self.data = {}
self.update(other, **kw)

def _commit_removals(self):
def _commit_removals(self, _atomic_removal=_remove_dead_weakref):
pop = self._pending_removals.pop
Comment thread
graingert marked this conversation as resolved.
d = self.data
# We shouldn't encounter any KeyError, because this method should
Expand All @@ -130,7 +130,7 @@ def _commit_removals(self):
except IndexError:
return
else:
_remove_dead_weakref(d, key)
_atomic_removal(d, key)

def __getitem__(self, key):
if self._pending_removals:
Expand Down