I would be sure that the python equality operator would be efficient enough to compare compositions of inline objects. I expect this to be faster than etching + hashing, provided that the python tests for list equality look something like this:
def __eq__(a,b): if type(a) == list and type(b) == list: if len(a) != len(b): return False for i in range(len(a)): if a[i] != b[i]: return False return True
Since the function returns as soon as it finds two elements that do not match, in the average case it will not need to iterate over all this. Compare with hashing, which you need to iterate over the entire data structure, even in the best case.
Here's how I would do it:
import copy def perform_a_bunch_of_operations(data):
This has the disadvantage that you need to make a deep copy of your data at each iteration, but it can be faster than hashing - you can only know exactly by profiling your particular case.
Kevin source share