[ python-Feature Requests-1451588 ] bisect should support a custom comparison function

SourceForge.net noreply at sourceforge.net
Mon Apr 3 14:57:28 CEST 2006


Feature Requests item #1451588, was opened at 2006-03-16 19:26
Message generated for change (Comment added) made by splitscreen
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1451588&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jonathan S. Joseph (jsjoseph)
Assigned to: Nobody/Anonymous (nobody)
Summary: bisect should support a custom comparison function

Initial Comment:
The 'bisect' module provides functions for finding the
proper insertion point of an item in a sorted list. 

The sort() function for lists supports passing in a
custom comparison function, however none of the
functions in bisect() support this. The method used by
bisect to find the proper insertion point is not
documented, but I guess the module relies on a natural
ordering for the items, or on the items of the list
implementing __cmp__. 

I suggest adding a 5th argument, with keyword 'cmp', to
the functions in the 'bisect' module that would allow
supplying a custom comparison function, as for 'sort'.

bisect_left(  	list, item[, lo[, hi]][,cmp])
bisect_right( 	list, item[, lo[, hi]][,cmp])
bisect(...)
insort_left( 	list, item[, lo[, hi]][,cmp])
insort_right( 	list, item[, lo[, hi]][,cmp])
insort(...)

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

Comment By: Matt Fleming (splitscreen)
Date: 2006-04-03 12:57

Message:
Logged In: YES 
user_id=1126061

See patch #1462228.

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

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


More information about the Python-bugs-list mailing list