@@ -67,6 +67,7 @@ def __init__(self, dynprompt, node_ids, is_changed_cache):
67
67
super ().__init__ (dynprompt , node_ids , is_changed_cache )
68
68
self .dynprompt = dynprompt
69
69
self .is_changed_cache = is_changed_cache
70
+ self .immediate_node_signature = {}
70
71
self .add_keys (node_ids )
71
72
72
73
def include_node_id_in_input (self ) -> bool :
@@ -94,6 +95,8 @@ def get_immediate_node_signature(self, dynprompt, node_id, ancestor_order_mappin
94
95
if not dynprompt .has_node (node_id ):
95
96
# This node doesn't exist -- we can't cache it.
96
97
return [float ("NaN" )]
98
+ if node_id in self .immediate_node_signature : # reduce repeated calls of ancestors
99
+ return self .immediate_node_signature [node_id ]
97
100
node = dynprompt .get_node (node_id )
98
101
class_type = node ["class_type" ]
99
102
class_def = nodes .NODE_CLASS_MAPPINGS [class_type ]
@@ -108,6 +111,7 @@ def get_immediate_node_signature(self, dynprompt, node_id, ancestor_order_mappin
108
111
signature .append ((key ,("ANCESTOR" , ancestor_index , ancestor_socket )))
109
112
else :
110
113
signature .append ((key , inputs [key ]))
114
+ self .immediate_node_signature [node_id ] = signature
111
115
return signature
112
116
113
117
# This function returns a list of all ancestors of the given node. The order of the list is
0 commit comments