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: Priority queue realization issue
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: docs@python, dupeljan, rhettinger
Priority: normal Keywords:

Created on 2020-10-30 06:40 by dupeljan, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg379922 - (view) Author: Даниил Ляхов (dupeljan) Date: 2020-10-30 06:40
In Priority queue realization in docs https://docs.python.org/3/library/heapq.html there is no appointments that priority can be equal and the task can have different type. For example, if you store number of graph node in your priority queue, than it is possible to get "TypeError: '<' not supported between instances of 'int' and 'str'", because inside heappop there is comparison between elements, and if the fist elements the same, than it compare tasks, which can be tagged as removed and has '<removed-task>' value as opposed to number of node, which is int.
msg380037 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-10-31 04:23
The previous example, PrioritizedItem, shows how to address the issue.
History
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86367
2020-10-31 04:23:17rhettingersetstatus: open -> closed
resolution: not a bug
messages: + msg380037

stage: resolved
2020-10-30 09:24:06rhettingersetassignee: docs@python -> rhettinger

nosy: + rhettinger
2020-10-30 06:40:34dupeljancreate