Python 3.0 - is this true?

Rhamphoryncus rhamph at gmail.com
Mon Nov 10 20:43:59 CET 2008


On Nov 10, 8:16 am, Terry Reedy <tjre... at udel.edu> wrote:
> Duncan Grisby wrote:
> > In article <mailman.3702.1226203508.3487.python-l... at python.org>,
> >  Terry Reedy  <tjre... at udel.edu> wrote:
>
> >> Have you written any Python code where you really wanted the old,
> >> unpredictable behavior?
>
> > 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.

It's actually worse than that: A different input within a single
session will produce different results.  Sorting relies on
transitivity, and comparing such types doesn't provide it.

You might as well comment out the sort and call it good.  That's what
you really had in 2.x.  It was close enough most of the time to *look*
right, yet in truth it silently failed.  3.0 makes it an explicit
failure.

(There were some situations that worked, but they're exceptional.  You
can still do them now, but you need to be explicit (via a key function
or a special singleton.))



More information about the Python-list mailing list