heapq question

Giampaolo Rodola' gnewsg at gmail.com
Sat Jul 12 19:50:18 CEST 2008

this is related to what I'm trying to implement here:

My question is the following: is it safe to avoid to re-heapify() a
heap when I remove or move an element which is not the first one?

>>> from heapq import *
>>> heap = [2,4,6,7,1,2,3]
>>> heapify(heap)
>>> del heap[4]
>>> # Am I forced to heapify() the heap here?

Thanks in advance.

--- Giampaolo

More information about the Python-list mailing list