how to convert code that uses cmp to python3

Marko Rauhamaa marko at pacujo.net
Fri Apr 8 00:17:46 EDT 2016


Ian Kelly <ian.g.kelly at gmail.com>:

> On Thu, Apr 7, 2016 at 1:32 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> I use AVL trees to implement timers. You need to be able to insert
>> elements in a sorted order and remove them quickly.
>
> Why would AVL trees implementing timers ever need non-numeric keys
> though?
>
> It seems to me that if you're mixing types like this then the ordering
> is likely not actually important.

The keys are expiry times. You could use numbers or you could use
datetime objects.

Ordering is crucial when it comes to timers.


Marko



More information about the Python-list mailing list