[PYTHON MATRIX-SIG] type coercion one more time

Paul. Dubois dubois1@llnl.gov
Thu, 25 Jan 1996 11:43:31 -0800

I have been busy giving talks and attending meetings, etc., and had a
hard time plowing through all this carefully. If I understand the latest
idea with respect to precision, I think I can live with it but I don't
like it. It would violate the principle of least surprise. 

It essentially changes the precision of the scalars in Python iff they
get involved with doing something with Array_f's. I don't like
exceptions in languages. Exceptions lead to weird behavior.

For example, we all agree it is a Good Thing that x[i] is a scalar not
an array of size 1. But in fact this means that 
(1./3.) * x[i] is not ((1./3.) * x)[i] if x is Array_f.

I agree it is nice to go fast but let's not go too fast.

I thought the "generic" stuff was off track. Everybody who writes
anything that handles Arrays has enough trouble without one more type to
look for.

Jim, what you need to do in your own work can be pretty much solved with
a little literal function:
def lit(d):
	return Array_f(d)

so that you just always say lit(2.) rather than 2. You have to train
yourself to do this in the places where it matters, true, but otherwise
you are just going to make the rest of us miserable.
Paul F. Dubois, L-472				(510)-422-5426
Lawrence Livermore National Laboratory		FAX (510)-423-9969
Livermore, CA 94550				dubois1@llnl.gov
Consulting: PaulDubois@aol.com

MATRIX-SIG  - SIG on Matrix Math for Python

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