提交 0e918833 authored 作者: Frederic Bastien's avatar Frederic Bastien 提交者: Reyhane Askari

small speed up

上级 edaa6913
...@@ -948,9 +948,11 @@ def general_toposort(outputs, deps, debug_print=False, ...@@ -948,9 +948,11 @@ def general_toposort(outputs, deps, debug_print=False,
rlist.append(node) rlist.append(node)
rset.add(node) rset.add(node)
for client in _clients.get(node, []): for client in _clients.get(node, []):
d = [a for a in deps_cache[client] if a is not node]
deps_cache[client] = d
deps_cache[client] = [a for a in deps_cache[client] deps_cache[client] = [a for a in deps_cache[client]
if a is not node] if a is not node]
if not deps_cache[client]: if not d:
sources.append(client) sources.append(client)
if len(rlist) != len(reachable): if len(rlist) != len(reachable):
...@@ -1023,7 +1025,7 @@ def io_toposort(inputs, outputs, orderings=None, clients=None): ...@@ -1023,7 +1025,7 @@ def io_toposort(inputs, outputs, orderings=None, clients=None):
rval = list(obj.inputs) rval = list(obj.inputs)
rval.extend(orderings.get(obj, [])) rval.extend(orderings.get(obj, []))
else: else:
assert not orderings.get(obj, []) assert not orderings.get(obj, None)
return rval return rval
topo = general_toposort(outputs, deps=compute_deps, topo = general_toposort(outputs, deps=compute_deps,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论