[New-bugs-announce] [issue7734] discuss mark-as-invalid trick in heapq docs

Joshua Bronson report at bugs.python.org
Mon Jan 18 23:07:47 CET 2010


New submission from Joshua Bronson <jabronson at gmail.com>:

Though the heapq module does not support changing the priority of a particular element of the heap (a necessary operation for the A* search family of algorithms), such an element can be marked as invalid and a new element can be added with different priority. Any element marked as invalid that makes it to the top of the heap can simply be popped off and ignored.

Users who haven't seen this trick before might mistakenly think the heapq module does not provide sufficient operations to implement A* search.

Please see the recent thread on comp.lang.python for more background:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/8adc3ce8d2219647

----------
assignee: georg.brandl
components: Documentation
messages: 98034
nosy: georg.brandl, jab, rhettinger
severity: normal
status: open
title: discuss mark-as-invalid trick in heapq docs
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7734>
_______________________________________


More information about the New-bugs-announce mailing list