[Patches] [ python-Patches-866594 ] heapq: A way to change the compare function

SourceForge.net noreply at sourceforge.net
Wed Dec 31 13:38:45 EST 2003


Patches item #866594, was opened at 2003-12-28 05:06
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=866594&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Miki Tebeka (tebeka)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: heapq: A way to change the compare function

Initial Comment:
It'd be nice if heapq could use a custom compare function.
This way the user won't need to write a class with <=
method.

I've added set_cmp(cmp=None) for setting the
comparision function. Using cmp and not expliclty <=
makes later changes in implementation easier.

Attached are the diffs.

BTW: I know in CVS heapq is a C module now, don't have
the  time to change my patch...

Miki


----------------------------------------------------------------------

Comment By: Michael Chermside (mcherm)
Date: 2003-12-29 09:53

Message:
Logged In: YES 
user_id=99874

Can you explain better the motivation for adding this? I don't 
find writing __le__() to be a significant problem normally, and 
setting the global _le seems a less-than-perfect design. What 
is a use case?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=866594&group_id=5470



More information about the Patches mailing list