--- id: toposort version: "1.10" license: Apache License Version 2.0 license_treatment: permissive maintenance: abandoned --- # toposort — Implements a topological sort algorithm. License: permissive · Maintenance: abandoned · Downloads: 13.0M/mo ## What it is and what it does toposort is a pure Python implementation of the topological sorting algorithm. It takes a dictionary where each key is a node and its value is a set of nodes it depends on, then returns an iterator of sets representing valid processing orders—nodes with no remaining dependencies come first. If a circular dependency exists, it raises CyclicDependencyError with details about the cycle. The package is straightforward and self-contained, with no external runtime dependencies. It supports both granular iteration (toposort) and flattened output (toposort_flatten), making it suitable for build systems, task scheduling, and any workflow requiring dependency resolution. The implementation handles arbitrary hashable node types, not just integers. Use it for: - Determine build order for interdependent software modules or packages. - Schedule task execution respecting prerequisite constraints in workflow systems. - Resolve import or initialization order in complex codebases with circular-dependency detection. - Order database migrations or schema changes based on foreign-key dependencies. - Compute execution order for computation graphs in data pipelines. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Implements topological sorting of directed acyclic graphs, ordering nodes so dependencies are processed before dependents. Yes, if you need a simple, dependency-free topological sort. The algorithm is stable and well-tested (Production/Stable status), and the abandoned maintenance status poses minimal risk for a mature, narrow-scope library. Use it for straightforward dependency ordering; if you need advanced graph algorithms or active support, consider alternatives. ## Install pip install toposort uv add toposort poetry add toposort ## Installing toposort Before you install: Low install friction with no runtime dependencies. Package is marked abandoned (last release 2023-02-25, 1266 days ago), so expect no active maintenance or bug fixes. License in practice: Apache License 2.0 (permissive) allows use in most projects without significant restrictions. Quickstart: from toposort import toposort, toposort_flatten data = {2: {11}, 9: {11, 8, 10}, 10: {11, 3}, 11: {7, 5}, 8: {7, 3}} result = list(toposort(data)) flat = toposort_flatten(data) Verify before relying: - Whether the abandoned status affects reliability for stable, well-tested algorithms like topological sort. - Performance characteristics on large graphs or whether there are known limitations in the implementation. ## Package facts - License: Apache License Version 2.0 (permissive) - Python support: unspecified - Install friction: low - Maintenance: abandoned - Downloads: 13.0M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags topological sort, dependency ordering, directed acyclic graph, toposort algorithm, process dependencies in order, circular dependency detection, node ordering, graph-algorithms, dependency-resolution [View on SkillFed](https://skillfed.io/packages/toposort) · [View on PyPI](https://pypi.org/project/toposort/)