On Fri, 8 Apr 2016 05:45 pm, Antoon Pardon wrote: > Op 07-04-16 om 23:08 schreef Ben Finney: >> 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. > > And nobody thought about this kind of cases or found them important > enough?
Probably not. But you know, if you can demonstrate a genuine and severe slowdown with no easy work-around, you should report it as a bug. It wouldn't be the first time that functions removed from Python 3 have been re-added because it turned out that they were needed. >> 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’. > > I'll have a look. I would be stunned if tuple comparisons with only a handful of values were slow enough that its worth caching their results with an lru_cache. But try it, and see how you go. -- Steven -- https://mail.python.org/mailman/listinfo/python-list