Skip to content

Archive

Graphlib

1 articles
Python 04 Sep 2026 8 min read

Order Dependency-Driven Work in Python with graphlib.TopologicalSorter

Many automation tasks are not really lists. They are dependency graphs. A deployment may need a database migration before the API starts, while static assets can build independently. A data pipeline may need two source extracts before a join can run. A build system may have several targets that become runnable as soon as their prerequisites finish. If you encode this work as one hand-written sequence, you hide the real constraint: which tasks depend on which other tasks. That makes the sequence harder to change and can prevent independent work from running concurrently.