Skip to main content

Data Structures & Collections

This section covers Python's built-in modules for working with specialized data structures and container types.

📦 Modules

Core Collections

  • collections - Specialized container datatypes like Counter, defaultdict, deque
  • array - Efficient arrays of numeric values with type constraints

Algorithms & Utilities

  • heapq - Heap queue algorithm (priority queue)
  • bisect - Array bisection algorithm for maintaining sorted lists
  • enum - Support for enumerations and symbolic constants

🔍 Quick Reference

ModulePurposeKey Classes/Functions
collectionsSpecialized containersCounter, defaultdict, deque, namedtuple
arrayTyped arraysarray()
heapqPriority queuesheappush(), heappop(), heapify()
bisectBinary searchbisect_left(), bisect_right(), insort()
enumEnumerationsEnum, IntEnum, Flag