how to convert code that uses cmp to python3
Antoon Pardon
antoon.pardon at rece.vub.ac.be
Fri Apr 8 03:45:54 EDT 2016
Op 07-04-16 om 23:08 schreef Ben Finney:
> Antoon Pardon <antoon.pardon at 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?
> 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.
--
Antoon
More information about the Python-list
mailing list