Use even better/faster set comparison
This commit is contained in:
parent
55f2b00366
commit
2d48127e9c
|
@ -139,10 +139,9 @@ def follow_node_log(config, node, lines=10):
|
||||||
# Set the node log to the new log value for the next iteration
|
# Set the node log to the new log value for the next iteration
|
||||||
node_log = new_node_log
|
node_log = new_node_log
|
||||||
|
|
||||||
# Get the set difference between the two sets of lines
|
# Get the difference between the two sets of lines
|
||||||
# We can safely use sets here since, due to the timestamps, we can guarantee that every
|
old_node_loglines_set = set(old_node_loglines)
|
||||||
# individual log line is distinct, and similarly we can re-sort the diff afterwards.
|
diff_node_loglines = [x for x in new_node_loglines if x not in old_node_loglines_set]
|
||||||
diff_node_loglines = sorted(list(set(new_node_loglines) - set(old_node_loglines)))
|
|
||||||
|
|
||||||
# If there's a difference, print it out
|
# If there's a difference, print it out
|
||||||
if len(diff_node_loglines) > 0:
|
if len(diff_node_loglines) > 0:
|
||||||
|
|
Loading…
Reference in New Issue