In article <[EMAIL PROTECTED]>, Terry Reedy <[EMAIL PROTECTED]> wrote:
>> I have an object database written in Python. It, like Python, is >> dynamically typed. It heavily relies on being able to sort lists where >> some of the members are None. To some extent, it also sorts lists of >> other mixed types. It will be very hard to migrate this aspect of it >> to Python 3. > >Very Hard? Several key functions have been suggested on this thread. >Given that 2.x only sorts most but not all types and that the sort is >only guaranteed to be consistent within a session, as I remember, I >suspect you can choose or write something at least as good for your >purposes. Yes, very hard. There are only ever simple types in the lists -- strings, integers, Nones, very occasionally floats, and lists of those things. The sort is always predictable with those types. Just because you can contrive situations to demonstrate unpredictable sorts doesn't mean that all sorts with mixed types are unpredictable. The sorting is in a performance-critical part of the system, so the overhead of evaluating a key function is not insignificant. A key function that returns objects that contrive to emulate the functionality of a comparison function is definitely not appropriate. That area of the system already builds the lists using C++ for speed, so if we ever migrate to Python 3 it will probably be easier to do the whole thing in C++ rather than jump through hoops to make the Python sort work efficiently enough. Cheers, Duncan. -- -- Duncan Grisby -- -- [EMAIL PROTECTED] -- -- http://www.grisby.org -- -- http://mail.python.org/mailman/listinfo/python-list