New submission from Dan Uznanski <[EMAIL PROTECTED]>: Attached find a unified diff that upgrades the bisect module in two important ways:
1. bisect and friends now understand cmp, key, and reverse, the same way that list.sort does. 2. bisect and insort now have parameterized handedness: instead of using two different functions depending on whether you want new items to show up before or after existing ones, bisect and insort now take a flag called 'right' which can change the handedness on the fly. Currently this code fails two existing regression tests: test_backcompatibility, because bisect is no longer the same as bisect_right; and test_non_sequence, because insort now raises AttributeError instead of TypeError when called on an int. Still to do, in order of priority as perceived by me: 1. A C version of the code needs to be written. 2. The error handling should be worked over by somebody with more knowledge than I - the regression tests assume that particular failures (len-only, get-only, and non-sequence) will happen with one of TypeError or AttributeError when in reality they may raise the other. 3. The tests for new functionality should be made more exhaustive. 4. The in-module documentation probably needs cleaning; the rst documentation needs my name added to it (a good deal of the existing writing is still Fred L Drake's, so I won't replace) and needs to have the "section 3.6.4" part linked to Mutable Sequence Types; I couldn't find an actual example of that linkage. 5. The godawful conditions in bisect should probably get cleaned up. ---------- components: Library (Lib) files: bisect-2.7.diff keywords: patch messages: 69773 nosy: dan.uznanski severity: normal status: open title: Bisect upgrades: key/cmp/reverse, parameterized handedness versions: Python 2.7 Added file: http://bugs.python.org/file10904/bisect-2.7.diff _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3374> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com