New submission from Joshua Bronson <jabron...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue7734>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to