Opened 56 minutes ago
Last modified 47 minutes ago
#37126 new New feature
Make Task and TaskResult comparable
| Reported by: | Johannes Maron | Owned by: | |
|---|---|---|---|
| Component: | Tasks | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Johannes Maron | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
Python's queue.PriorityQueue implementation requires objects to be comparable.
Since the base implementation of a Task implements a priority, it only makes sense to provide basic comparability based on the priority and date.
Dataclasses have a neat order=True attribute to make this stupidly simple.
Note:
See TracTickets
for help on using tickets.
I would also suggest adding a custom eq method. We only need to include
idand a simple string comparison is much quicker. Benchmarks N = 100_000_000: