[Python-Dev] Re: lists v. tuples
Alex Martelli
aleax@aleax.it
Sat, 15 Mar 2003 08:57:53 +0100
On Friday 14 March 2003 04:42 pm, Christian Tismer wrote:
> Alex Martelli wrote:
> ...
>
> > Sorting plays with mutability by working in-place, but for many
> > uses it would be just as good if sorting returned a sorted copy
> > instead -- the key thing here is the sorting, not the mutability.
>
> And the key assumption for sorting things is that
> the things are sortable, which means there
> exists and order on the basic set.
> Which again suggests that list elements usually
> have something in common.
If a list contains ONE complex number and no other number,
then the list can be sorted.
If the list contains elements that having something in common,
by both being complex numbers, then it cannot be sorted.
So, lists whose elements have LESS in common (by being of
widely different types) are more likely to be sortable than lists
some of whose elements have in common the fact of being
numbers (if one or more of those numbers are complex).
Although not likely to give practical problems (after all I suspect
most Pythonistas never use complex numbers at all), this
anomaly (introduced in 1.6, I think) makes conceptualization
less uniform and thus somewhat harder to teach.
Alex