This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add example to priority queue
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.8
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Windson Yang, docs@python, rhettinger
Priority: normal Keywords:

Created on 2019-04-26 03:01 by Windson Yang, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg340878 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-04-26 03:01
We don't have the base example for priority queue in https://docs.python.org/3.8/library/heapq.html#priority-queue-implementation-notes, We can add something like:

> q = Q.PriorityQueue()
> q.put(10)
> q.put(1)
> q.put(5)
> while not q.empty():
    print q.get()

We may also need to add Notes about the PriorityQueue will block when we use max size 

> q = Q.PriorityQueue(1)
> q.put(10)
> q.put(1) # will block until the Queue is available again.
msg340891 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-04-26 07:43
This doesn't make any sense.  None of those operations are defined for the heapq module, nor is there a maxsize.  The heapq usage notes are about the general concept of ways to implement priority queues.  I suspect your suggestion is conflated with queue.PriorityQueue() which does have put(), get(), and maxsize.

As for the queue docs, I don't think more examples are needed. IMO it would just clutter that part of the docs.
History
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 80912
2019-04-26 07:43:22rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg340891

resolution: rejected
stage: resolved
2019-04-26 03:01:37Windson Yangcreate