Antoon Pardon <antoon.par...@rece.vub.ac.be> writes: > With this method I have to traverse the two tuples almost always > twice. Once to find out if they are equal and if not a second time to > find out which is greater.
You are essentially describing the new internal API of comparison operators. That's pretty much unavoidable. If you want to avoid repeating an expensive operation – the computation of the comparison value for an object – you could add an LRU cache to that function. See ‘functools.lru_cache’. -- \ “He that would make his own liberty secure must guard even his | `\ enemy from oppression.” —Thomas Paine | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list