[Python-Dev] Tuples and underorderable types

Terry Reedy tjreedy at udel.edu
Sat Apr 25 03:16:24 CEST 2009

Raymond Hettinger wrote:
>> I would discourage use of the decorate/sort/undecorate pattern,
>> and encourage use of the key= argument. Or, if you really need
>> to decorate into a tuple, still pass a key= argument.
> The bug report was actually about the sched module which used
> heapq to prioritize tuples consisting of times, priorities, and actions.
> I fixed and closed the original bug a few hours ago but had a
> thought that the pattern itself may be ubiquitious (especially with heapq).
> ISTM that other bugs like this are lurking about.  But all of you guys 
> seem to think the status quo is fine, so that's the end of it.

If you define the bug as the sched module not being updated to the 3.0 
order, then there are possibly more.

I notice that most of the heapq functions do not take a key function 
argument.  Has or will this change in the future?  Or is making 
key-decorated tuples the responsibility of the user?  (I can see that a 
key func would work better with PriQueue class where the key func is 
passed just once.)


More information about the Python-Dev mailing list