Skip to main content

Addressable priority queue data structures

Project description

apq

apq provides different kinds of addressable priority queue data structures usable in any Python 3 project.

All priority queues provided by apq are backed by a C++ binary heap implementation. The priority queue types exposed to Python are implemented in Cython. Type stubs are installed along with the package so that mypy can fully check dependent code.

Priority Queue Types

  • KeyedPQ - This priority queue allows lookup of entries through a string key. That means it combines an addressable priority queue with a dictionary creating a str to item mapping (almost implementing typing.Mapping[str, Item]). KeyedPQ is recommended whenever individual entries are looked up using a key.

Quickstart

Installation:

$ pip install apq

Usage:

>>> from apq import KeyedPQ
>>> pq: KeyedPQ[None] = KeyedPQ()
>>> pq.add('my_first_key', 34.0, None)
<apq.Item object at 0x7f506884bd70>
>>> pq.add('my_second_key', 36.0, None)
<apq.Item object at 0x7f506884bcb0>
>>> pq.change_value('my_second_key', 12.0)
<apq.Item object at 0x7f50663604f0>
>>> print(pq.pop())
('my_second_key', 12.0, None)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apq-0.6.2.tar.gz (71.5 kB view hashes)

Uploaded Source

Built Distributions

apq-0.6.2-cp38-cp38-manylinux2014_x86_64.whl (490.5 kB view hashes)

Uploaded CPython 3.8

apq-0.6.2-cp38-cp38-manylinux2010_x86_64.whl (609.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

apq-0.6.2-cp38-cp38-manylinux2010_i686.whl (451.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

apq-0.6.2-cp37-cp37m-manylinux2014_x86_64.whl (477.9 kB view hashes)

Uploaded CPython 3.7m

apq-0.6.2-cp37-cp37m-manylinux2010_x86_64.whl (593.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

apq-0.6.2-cp37-cp37m-manylinux2010_i686.whl (437.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

apq-0.6.2-cp36-cp36m-manylinux2014_x86_64.whl (478.5 kB view hashes)

Uploaded CPython 3.6m

apq-0.6.2-cp36-cp36m-manylinux2010_x86_64.whl (594.2 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

apq-0.6.2-cp36-cp36m-manylinux2010_i686.whl (438.9 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page