Skip to main content

DepqDict

PyPI version PyPI - Python Version Project Status: Active – The project has reached a stable, usable state and is being actively developed. Ruff License: GPL v3

DepqDict is an efficient double-ended priority queue implemented in Python. It allows efficient retrieval and extraction of the minimum and maximum priority elements, as well as updating priorities of arbitrary elements. Implemented using a min-max heap.

Features

  • Supports both min and max priority queue operations.
  • Efficient push and pop operations for both min and max elements.
  • Allows updating priorities of arbitrary keys.
  • Implements the MutableMapping interface, behaving like a dictionary.

Installation

You can install DepqDict from PyPI using pip:

pip install depqdict

Usage

from depqdict import DepqDict

pq = DepqDict()
pq['task1'] = 5
pq['task2'] = 2
pq['task3'] = 8

print(pq.min_item())  # ('task2', 2)
print(pq.max_item())  # ('task3', 8)

pq['task1'] = 1  # Update priority
print(pq.min_item())  # ('task1', 1)

pq.pop_min_item()  # Removes ('task1', 1)

API with Runtimes

Retrieve Min/Max Items

pq.min_item()  # O(1)
pq.max_item()  # O(1)

Returns the key-value pair with the lowest or highest priority.

Remove Min/Max Items

pq.pop_min_item()  # O(log n)
pq.pop_max_item()  # O(log n)

Removes and returns the key-value pair with the lowest or highest priority.

Push-Pop Operations

pq.push_pop_min_item('task4', 3)  # O(log n)
pq.push_pop_max_item('task5', 9)  # O(log n)

Pushes a new key-priority pair into the queue and returns the smallest or largest item. Faster than using two separate operations.

Insert or Update a Key

pq['task6'] = 4  # O(log n)

Inserts or updates the priority of a key.

Delete a Key

del pq['task3']  # O(log n)

Removes a key from the queue.

License

This project is licensed under the GPL-3.0 License, as it is based on heapdict by Evgeniy Selezniov, which is also licensed under GPL-3.0. See the LICENSE file for details.

Acknowledgments

This package is based on heapdict, originally developed by Evgeniy Selezniov.

Metadata

Release files for depqdict 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for depqdict 0.1.1
File Size Uploaded Provenance
depqdict-0.1.1.tar.gz 38.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for depqdict 0.1.1
File Interpreter ABI Platform
depqdict-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 56.4 kB

Release files / depqdict-0.1.1.tar.gz

Download URL depqdict-0.1.1.tar.gz
Size 38.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0073963c89f15da8e81086222ac4e47a5f22591877fdb73aaf911db293473e1d
BLAKE2b-256 checksum
How to use checksums
5ab00a666363306520dee9b87812ef833eb3dbe9196ac5266779bae0c51733a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.4

Release files / depqdict-0.1.1-py3-none-any.whl

Download URL depqdict-0.1.1-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ac1df4845fb72dcec9fbc53df7d272601ff4e27e552e0c0915fd6249578bb8c
BLAKE2b-256 checksum
How to use checksums
06799b62d12aa524d2a4cc7a9cef08688a819d11c568479f5043f924b453d142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.4

Security for depqdict 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page