summaryrefslogtreecommitdiffstats
path: root/Doc/library/queue.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2018-01-12 06:06:34 (GMT)
committerGitHub <noreply@github.com>2018-01-12 06:06:34 (GMT)
commit0c3be9651f4f149f4a78bb7043d26db9e75cabc0 (patch)
tree02b29ce454a2bbe8a18d7afa9a54cea5c6421c06 /Doc/library/queue.rst
parent02556fbade5e1e864dd09d5768a8dbbf5b3a0dac (diff)
downloadcpython-0c3be9651f4f149f4a78bb7043d26db9e75cabc0.zip
cpython-0c3be9651f4f149f4a78bb7043d26db9e75cabc0.tar.gz
cpython-0c3be9651f4f149f4a78bb7043d26db9e75cabc0.tar.bz2
bpo-31145: Use dataclasses to create a prioritization wrapper (#5153)
Diffstat (limited to 'Doc/library/queue.rst')
-rw-r--r--Doc/library/queue.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/library/queue.rst b/Doc/library/queue.rst
index bd0fc2d..f9a43bb 100644
--- a/Doc/library/queue.rst
+++ b/Doc/library/queue.rst
@@ -56,6 +56,16 @@ The :mod:`queue` module defines the following classes and exceptions:
one returned by ``sorted(list(entries))[0]``). A typical pattern for entries
is a tuple in the form: ``(priority_number, data)``.
+ If the *data* elements are not comparable, the data can be wrapped in a class
+ that ignores the data item and only compares the priority number::
+
+ from dataclasses import dataclass, field
+ from typing import Any
+
+ @dataclass(order=True)
+ class PrioritizedItem:
+ priority: int
+ item: Any=field(compare=False)
.. exception:: Empty