Skip to main content

a heap with decrease-key and increase-key operations

Project description

heapdict implements the MutableMapping ABC, meaning it works pretty much like a regular Python dict. It’s designed to be used as a priority queue, where items are added and consumed as follows:

hd = heapdict()
hd[obj1] = priority1
hd[obj2] = priority2
# ...
obj = hd.pop()

Compared to an ordinary dict, a heapdict has the following differences:

popitem():

Remove and return the (key, priority) pair with the lowest priority, instead of a random object.

peekitem():

Return the (key, priority) pair with the lowest priority, without removing it.

Unlike the Python standard library’s heapq module, the heapdict supports efficiently changing the priority of an existing object (often called “decrease-key” in textbooks). Altering the priority is important for many algorithms such as Dijkstra’s Algorithm and A*.

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

HeapDict-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

HeapDict-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file HeapDict-1.0.0.tar.gz.

File metadata

  • Download URL: HeapDict-1.0.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for HeapDict-1.0.0.tar.gz
Algorithm Hash digest
SHA256 40c9e3680616cfdf942f77429a3a9e0a76f31ce965d62f4ffbe63a83a5ef1b5a
MD5 47320e136156593c84072d09e770800f
BLAKE2b-256 e2caf5feba2f939c97629dbce52a17acc95a0d10256ef620334795379dda8ce6

See more details on using hashes here.

File details

Details for the file HeapDict-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: HeapDict-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8rc1

File hashes

Hashes for HeapDict-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f7e4858afe3465d4693280c5ebd542d4e105eca98210d68ea8594fd501e81807
MD5 ce1a930f49c4eff4467cd18cc182987d
BLAKE2b-256 acaa867f3493599247eebb239588b030d7928fe6474d4454c45770aa78951164

See more details on using hashes here.

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