heapq question

Giampaolo Rodola' gnewsg at gmail.com
Sat Jul 12 13:50:18 EDT 2008


Hi,
this is related to what I'm trying to implement here:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/20796724c1daf1e1#

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?
Example:

>>> 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
http://code.google.com/p/pyftpdlib/




More information about the Python-list mailing list