MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / __delitem__

Method __delitem__

src/randomtrackingdict.py:46–65  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

44 self.len += 1
45
46 def __delitem__(self, key):
47 if not key in self.dictionary:
48 raise KeyError
49 with self.lock:
50 index = self.dictionary[key][0]
51 # not pending
52 if index < self.len - self.pendingLen:
53 # left of pending part
54 index = self._swap(index, self.len - self.pendingLen - 1)
55 # pending
56 else:
57 self.pendingLen -= 1
58 # end
59 self._swap(index, self.len - 1)
60 # if the following del is batched, performance of this single
61 # operation can improve 4x, but it's already very fast so we'll
62 # ignore it for the time being
63 del self.indexDict[-1]
64 del self.dictionary[key]
65 self.len -= 1
66
67 def setMaxPending(self, maxPending):
68 self.maxPending = maxPending

Callers

nothing calls this directly

Calls 1

_swapMethod · 0.95

Tested by

no test coverage detected