def __delitem__(self, key):
        """
        Remove item. Raises a ``KeyError`` if key is not in the pqdict.

        """
        heap = self._heap
        position = self._position
        pos = position.pop(key)  # raises KeyError
        node_to_delete = heap[pos]
        # Take the very last node and place it in the vacated spot. Let it
        # sink or swim until it reaches its new resting place.
        end = heap.pop(-1)
        if end is not node_to_delete:
            heap[pos] = end
            position[end.key] = pos
            self._reheapify(pos)
        del node_to_delete
def __delitem__ ( self , key ) : heap = self . _heap position = self . _position pos = position . pop ( key ) node_to_delete = heap [ pos ] end = heap . pop ( - 1 ) if end is not node_to_delete : heap [ pos ] = end position [ end . key ] = pos self . _reheapify ( pos ) del node_to_delete
Remove item. Raises a ``KeyError`` if key is not in the pqdict.