Antoon Pardon <antoon.par...@rece.vub.ac.be>: > In python2 descending the tree would only involve at most one > expensive comparison, because using cmp would codify that comparison > into an integer which would then be cheap to compare with 0. Now in > python3, I may need to do two expensive comparisons, because there is > no __cmp__ method, to make such a codefication.
I think you should base your tree implementation on key.__lt__() only. Only compare keys using <, nothing else, ever. It may lead to faster or slower performance, depending on the ordering function, but I think it is more minimalistic, and thus philosophically more appealing than __cmp__. Marko -- https://mail.python.org/mailman/listinfo/python-list