This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2006年03月16日 19:26 by jsjoseph, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg61225 - (view) | Author: Jonathan S. Joseph (jsjoseph) | Date: 2006年03月16日 19:26 | |
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(...) |
|||
| msg61226 - (view) | Author: Matt Fleming (splitscreen) | Date: 2006年04月03日 12:57 | |
Logged In: YES user_id=1126061 See patch #1462228. |
|||
| msg64401 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2008年03月24日 08:26 | |
Sorry, am closing this RFE because its not the best way to use the bisect tools. The cmp function is going away in Py3.0 in favor of key functions. Yet, even those do not play nicely with bisect because the function results are not stored between successive calls to bisect. Accordingly, it is almost always better to arrange the records in a decorated style so that they can be compared directly and not through a cmp or key function. The one misgiving is that is feels odd to be able to sort by a key function but not maintain that order or search that ordering using the bisect module. Yet, there is a simple reason for the difference -- sort () works on the entire sequence at once and can take advantage of the single key function call per element -- in contrast, the bisect functions have finer granularity and the cmp/key functions no longer make sense. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:15 | admin | set | github: 43042 |
| 2008年03月24日 08:26:41 | rhettinger | set | status: open -> closed resolution: rejected messages: + msg64401 nosy: + rhettinger |
| 2006年03月16日 19:26:31 | jsjoseph | create | |