Skip to content
Data Structures and Algorithms / Trees, Heaps, and Ordered Search

Python's Built-In ADTs: heapq, bisect, and dict/set in Practice

This unit has derived the cost guarantees of heaps, hash tables, and balanced search trees from first principles — the point of this closing lesson is to map those guarantees directly onto what a quant researcher actually types: heapq, bisect, dict, and set. Per this unit's "quant-practice-track" framing, most day-to-day work leans on these standard-library structures rather than hand-rolled red-black or B-trees, and knowing exactly which cost table each one inherits — and where the standard library has no built-in equivalent (an augmented balanced tree, notably) — is what turns the preceding lessons into usable engineering judgement rather than trivia.

In this lesson

  1. Learning objectives
  2. heapq: a min-heap, directly
  3. bisect: binary search on a sorted list, not a balanced tree
  4. dict and set: hash tables, with the same caveats
  5. The one genuine gap: augmented ordered structures

Before you start

The full lesson, with worked examples and exercise solutions, is for members.

Read the full lesson

New to SelfMadeQuant.com? See membership options or explore the curriculum.