Using DONE_SET method to make algorithm faster

What we do is like to maintain a dict {DONE_SET: memory peak}, then Each time when we execute Node X, we make a check if the peak in dict and the current peak bigger than that peak. If yes(or equal), break and start a new branch. if no, update the peak in dict and continue.
Instead of using list_set and list_mem, I would use a dict with key being the element of list_set and the value the element of list_mem.

But this get complicated as set aren't hashable and so can't be put in a dictionnary. I suppose you got hit by this problem and used list to work around that.

I see 2 possibles fix. But before, I think you know why it is better to use a dict here then list, but just in case, I'll write it. When you use a list and do a look up on it to find if one DONE_SET is in the list or not, you will compare that DONE_SET to each element of the list. This can be very slow if the list get big, and this will happen with git graph.

1) This is the fastest to implement fix, but probably not the fastest to run. You use a dict instead of list_set and list_mem. Then when you want to do operation on it, you convert DONE_SET to a frozenset (frozenset(DONE_SET)). frozenset are hashable and so can be used as key in dict.

2) The problem with 1, is that this request a convertion to a frozen set just to know if the done set have been seen. This can be optimized like the unsafe solution proposed here:

https://docs.python.org/3.3/faq/design.html#why-must-dictionary-keys-be-immutable

This also explain why we can't use set as key in dict.

Can you do 1) now, and check if this is speed up the logistic_sgd.py DLT example and check if it allow us to finish in a resonable time the logistic_cg.py example?

In fact, I would time this version on the logistic_sgd.py, and time the frozen version with it. I think the frozen version should be faster, but implementation detail could make this False.