how to convert code that uses cmp to python3

Antoon Pardon antoon.pardon at rece.vub.ac.be
Fri Apr 8 10:22:07 EDT 2016


Op 08-04-16 om 15:52 schreef Marko Rauhamaa:
> Antoon Pardon <antoon.pardon at rece.vub.ac.be>:
>
>> Well having a list of 1000 Sequence like object. Each sequence
>> containing between 1 and 100 numbers. Comparing each sequence
>> to each other a 100 times. I get the following results.
>>
>> Doing it as follows:
>>     seq1 < seq2
>>     seq2 < seq1
>>
>> takes about 110 seconds.
>>
>> Doing it like this:
>>     delta = cmp(seq1, seq2)
>>     delta < 0
>>     delta > 0
>>
>> takes about 50 seconds.
> Looks like a completely artificial scenario.
>
It is the code I run when I traverse a tree
and decide either to go left, right or have
found the node I am looking for.

And yes I have worked with keys like that.

-- 
Antoon




More information about the Python-list mailing list