Re: Comparison of functions
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Comparison of functions

From: Adriano Varoli Piazza <moranar@alice.it>
Date: Sat Jul 30 2005 - 18:13:22 CEST

Steven D'Aprano ha scritto:

> It was easy. I never once asked myself whether some complex number was
> greater or less than another, I just asked "which one comes first in a
> lexicographic sort?"
>
> The two questions are NOT the same, and it is an ugliness in an otherwise
> beautiful language that Python treats them as the same.
>
> Mathematically, 1 == 1.0 == 1+0j but in the dictionary "1" should sort
> before "1.0" which sorts before "1.0+0.0j".

Because, of course, when I sort numbers the first thing I think of is
looking at the ascii table... Here I was, thinking maths was useful.
Sorting numbers "lexicographically" might make sense to you, but it's
totally unintuitive to me. For example, why or how would I guess that
"3-3j" is bigger (or smaller) than "3+3j"?

You'll still want to sort complex numbers lexicographically. It'll still
have no meaning whatsoever, so you might as well leave the list
unsorted. You might think you sorted something. 100? 200? years of maths
say you didn't.

-- 
Adriano Varoli Piazza
The Inside Out: http://moranar.com.ar
MSN: adrianomd@hotmail.com
ICQ: 4410132
Received on Thu Sep 29 17:15:46 2005