[PYTHON MATRIX-SIG] casting and default types

James Hugunin jjh@mama-bear.lcs.mit.edu
Tue, 7 Nov 95 10:12:44 -0500

I've had a couple of discussions with Jim Fulton about exactly this issue  
when I first grabbed his matrix object.  If he's reading this, I would  
really like to get his opinion.

I agree with you, and for my uses full automatic coercion as well as  
reasonable choices for matrix type in instantiation is a good idea.

The current instantiation (and lack of coercion) system is Jim Fulton's  
(more or less) and he could do a much better job of defending it than me.   
The principle issue is that automatic type coercions can hide bugs.  The  
other issue is that automatic coercion can hide efficiency problems.  If I  
have a vector of ints that I'm frequently going to have to multiply by  
different vectors of floats, then it would be much more efficient for me to  
convert it to a vector of floats one time.  If I have automatic type  
coercion, I might never even notice this problem (except that my multiply  
operation would be something like a factor of two slower).

This is why I mentioned this issue as something that might be amenable to  
some sort of flag in the same way that IEEE exceptions could be (I was just  
noticing that a system of this sort is enabled on the DEC alpha's).  If I  
want to be really careful, I'd insist that adding floats to ints raised an  
exception, and simlarly that dividing by zero would do the same.  If I was  
willing to play fast and loose then I could disable these forms of "error  
checking" and I'd be off.

Still not sure what's the "right" way,

MATRIX-SIG  - SIG on Matrix Math for Python

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