k3priorityqueue
priorityQueue is a queue with priority support
k3priorityqueue is a component of pykit3 project: a python3 toolkit set.
PriorityQueue is a queue with priority support:
The numbers of items it pops from each producer matches exactly the ratio of their priority: If the priorities of 3 producer A, B and C are 1, 3 and 7, and it runs long enough, it is expected that the number of items popped from A, B and C are 1:3:7.
import k3priorityqueue
producers = ( # id, priority, iterable (1, 1, [1] * 10), (2, 2, [2] * 10), (3, 3, [3] * 10),
)
pq = k3priorityqueue.PriorityQueue()
for pid, prio, itr in producers: pq.add_producer(pid, prio, itr)
count = {}
for _ in range(12): val = pq.get() count[val] = count.get(val, 0) + 1 print(val)
print('respect priority ratio: counts:', repr(count))
while True: try: val = pq.get() except k3priorityqueue.Empty as e: break
count[val] = count.get(val, 0) + 1
print(val)
print('consumed all: counts:', repr(count))
Install
pip install k3priorityqueue
Synopsis
import k3priorityqueue
producers = (
# id, priority, iterable
(1, 1, [1] * 10),
(2, 2, [2] * 10),
(3, 3, [3] * 10),
)
pq = k3priorityqueue.PriorityQueue()
for pid, prio, itr in producers:
pq.add_producer(pid, prio, itr)
count = {}
for _ in range(12):
val = pq.get()
count[val] = count.get(val, 0) + 1
print(val)
print("respect priority ratio: counts:", repr(count))
while True:
try:
val = pq.get()
except k3priorityqueue.Empty:
break
count[val] = count.get(val, 0) + 1
print(val)
print("consumed all: counts:", repr(count))
Author
Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Metadata
Release files for k3priorityqueue 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| k3priorityqueue-0.1.10.tar.gz | 7.4 kB | Without provenance | Details for k3priorityqueue-0.1.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| k3priorityqueue-0.1.10-py3-none-any.whl | Python 3 | none | any | Details for k3priorityqueue-0.1.10-py3-none-any.whl |
Total release size: 14.0 kB
Release files / k3priorityqueue-0.1.10.tar.gz
| Download URL | k3priorityqueue-0.1.10.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86369c033892f3101bca138ca832893ea6b1b08d25e28b1702bc6ced99a25b2f
|
|
BLAKE2b-256 checksum How to use checksums |
16989f9962d5a2ca4a76a691c923366dbc2bbc28e7fe4380de3e0d8ff5a2532f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / k3priorityqueue-0.1.10-py3-none-any.whl
| Download URL | k3priorityqueue-0.1.10-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b0c3d9229d3175ca249c2b5a5444da186379bc367fa86c7f3a3710ea88d672a
|
|
BLAKE2b-256 checksum How to use checksums |
8f78bd475ad35a00f593e7a0945085ad871649ef452e18fa01e14f3ac9bccd70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for k3priorityqueue 0.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.