[PYTHON MATRIX-SIG] Array comparisons, and determinants

Konrad Hinsen hinsen@ibs.ibs.fr
Sun, 27 Oct 96 10:22:17 GMT


> 1) We can go ahead and make ==/!= work now as returning 1/0 for arrays
> where all elements are equal and 0/1 where they're not. 
> 
> 2) We can deliberately cripple cmp so that it does nothing
> useful. This leaves the door open doing something fancy involving
> returning arrays later if __equal__, __lessthan__, etc. show up at a
> later date..
> 
> If we do 1), we're locked into using the comparison operators to
> return boolean values. I personally think this is the right way to go.

I agree. If we were designing Python from scratch, I'd certainly
favour giving comparisons an array result. Within Python as it is,
this would not only be difficult to implement, but inconsistent with
other existing data types (such as lists), which we can't change for
compatibility reasons.

If __cmp__ ever gets replaced by individual __less__, __greater__ etc.,
we can still give all those a useful meaning (as long as the result
is a boolean). For now, equality test is already useful (for integer
arrays more than for floats), and eliminates nasty surprises caused by
the address comparison strategy we currently have.

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================