如何在python中实现makefile样式的算法

Dav*_*ean 2 python algorithm makefile

我在python中实现了一个声学特征提取系统,我需要实现一个makefile风格的算法,以确保特征提取系统中的所有块都以正确的顺序运行,而不需要重复任何特征提取阶段.

此特征提取系统的输入将是一个详细说明特征提取块之间链接的图形,我想根据图形确定要运行的函数.

这种系统的一个例子可能如下:

            ,-> [B] -> [D] ----+
input --> [A]           ^      v
            `-> [C] ----+---> [E] --> output
Run Code Online (Sandbox Code Playgroud)

和函数调用(假设每个块X是表单的函数output = X(inputs)可能是这样的:

a = A(input)
b = B(a)
c = C(a)
d = D(b,c)  # can't call D until both b and c are ready
output = E(d,c)   # can't call E until both c and d are ready
Run Code Online (Sandbox Code Playgroud)

我已经以字典的形式加载了函数图,每个字典条目都是(inputs, function)这样的:

blocks = {'A' : (('input'), A),
          'B' : (('A'), B),
          'C' : (('A'), C),
          'D' : (('B','C'), D),
          'output' : (('D','C'), E)}
Run Code Online (Sandbox Code Playgroud)

我现在只是对makefile算法的确切内容以及如何实现它做了一个空白.我的google-fu似乎也不是很有帮助.如果有人至少可以给我一个指向良好讨论makefile算法的指针,这可能是一个好的开始.