Tag

heapq

1 views collected around this technical thread.

Test Development Learning Exchange
Test Development Learning Exchange
Aug 7, 2024 · Fundamentals

Python collections, heapq, bisect, and array modules: examples and usage

This article introduces Python's collections, heapq, bisect, and array standard‑library modules, explaining their purpose and providing clear code examples for namedtuple, deque, heap operations, binary search, and efficient array handling in everyday programming.

CollectionsData Structuresarray
0 likes · 4 min read
Python collections, heapq, bisect, and array modules: examples and usage
Test Development Learning Exchange
Test Development Learning Exchange
Jun 26, 2024 · Fundamentals

Python collections module: Counter, defaultdict, deque, namedtuple, ChainMap, custom containers, heapq, and LRU cache examples

This article introduces several useful classes from Python's collections module—including Counter, defaultdict, deque, namedtuple, ChainMap, UserList/UserDict/UserString, as well as heapq and an OrderedDict‑based LRU cache—explaining their purposes and providing ready‑to‑run code examples for each.

ChainMapCollectionsNamedtuple
0 likes · 6 min read
Python collections module: Counter, defaultdict, deque, namedtuple, ChainMap, custom containers, heapq, and LRU cache examples
Python Programming Learning Circle
Python Programming Learning Circle
Apr 22, 2020 · Fundamentals

Implementing a Priority Queue in Python Using heapq

This article explains how to implement a priority queue in Python using the built‑in heapq module, demonstrates extracting smallest and largest elements from price lists, and provides a full PriorityQueue class with push, pop, and is_empty methods, illustrated with stock portfolio examples.

AlgorithmPriority Queueheapq
0 likes · 6 min read
Implementing a Priority Queue in Python Using heapq