Skip to content

Commit 05f38b3

Browse files
committed
update not ready deps set with counter
1 parent 485f523 commit 05f38b3

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

mypy/build.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ def __init__(
230230
self.mod_ids = ids
231231
# Direct dependencies, should be populated by the caller.
232232
self.deps: set[int] = set(deps) if deps is not None else set()
233-
# Direct dependencies that have not been processed yet.
234-
# Should be populated by the caller. This set may change during graph
235-
# processing, while the above stays constant.
236-
self.not_ready_deps: set[int] = set()
233+
# Count of direct dependencies that have not been processed yet.
234+
# Populated by the caller (from len(deps)); decremented during graph
235+
# processing as each dep completes. self.deps above stays constant.
236+
self.not_ready_count: int = 0
237237
# SCCs that (directly) depend on this SCC. Note this is a list to
238238
# make processing order more predictable. Dependents will be notified
239239
# that they may be ready in the order in this list.
@@ -4630,10 +4630,11 @@ def process_graph(graph: Graph, manager: BuildManager) -> None:
46304630
ready = []
46314631
for done_scc in done:
46324632
for dependent in done_scc.direct_dependents:
4633-
scc_by_id[dependent].not_ready_deps.discard(done_scc.id)
4634-
if not scc_by_id[dependent].not_ready_deps:
4635-
not_ready.remove(scc_by_id[dependent])
4636-
ready.append(scc_by_id[dependent])
4633+
dep_scc = scc_by_id[dependent]
4634+
dep_scc.not_ready_count -= 1
4635+
if dep_scc.not_ready_count == 0:
4636+
not_ready.remove(dep_scc)
4637+
ready.append(dep_scc)
46374638
manager.trace(f"Transitive deps cache size: {sys.getsizeof(manager.transitive_deps_cache)}")
46384639

46394640

@@ -5014,9 +5015,10 @@ def prepare_sccs_full(
50145015
for scc in sccs:
50155016
# Remove trivial dependency on itself.
50165017
scc_deps_map[scc].discard(scc)
5017-
for dep_scc in scc_deps_map[scc]:
5018+
dep_sccs = scc_deps_map[scc]
5019+
for dep_scc in dep_sccs:
50185020
scc.deps.add(dep_scc.id)
5019-
scc.not_ready_deps.add(dep_scc.id)
5021+
scc.not_ready_count = len(dep_sccs)
50205022
return scc_deps_map
50215023

50225024

0 commit comments

Comments
 (0)