Improve the documented advice on how to best use heapq.heapreplace().

This commit is contained in:
Raymond Hettinger 2004-06-20 09:07:53 +00:00
parent 1761a7cc8b
commit 28224f897a
3 changed files with 10 additions and 3 deletions

View file

@ -186,7 +186,8 @@ PyDoc_STRVAR(heapreplace_doc,
This is more efficient than heappop() followed by heappush(), and can be\n\
more appropriate when using a fixed-size heap. Note that the value\n\
returned may be larger than item! That constrains reasonable uses of\n\
this routine.\n");
this routine unless written as part of a larger expression:\n\n\
result = item <= heap[0] and item or heapreplace(heap, item)\n");
static PyObject *
heapify(PyObject *self, PyObject *heap)