[PYTHON MATRIX-SIG] type coercion one more time

Hinsen Konrad hinsenk@ere.umontreal.ca
Thu, 25 Jan 1996 12:09:17 -0500

   On the other hand, I see the other types as being used for cases where
   the programmer really wants to use a particular precision, ie. 2-byte
   integers for dealing with 16-bit sound data.  In a case like this it
   seems decidely unfriendly to automatically coerce to another

I wouldn't call it "decidedly unfriendly" (you can always avoid
coercion by making sure that all variables have the same type), but it
makes sense. It should also be noted that one of the main reasons to
have float->double coercion in C is to make it possible to call
functions written for double with float arguments. This problem does
not exist in Python.

   4) Coercion to a higher precision is allowed within the main

What are "main groupings"?

   5) The precision of a python scalar is allowed to change to match the
   other arguments (3.14 can be either a float or a double depending on
   which one is "desired").

I don't like this rule for two reasons:
1) You can lose precision without noticing it.
2) It creates a subtle distinction between scalars and arrays of rank 0,
   which can only confuse users.

On the other hand, I do see the problem you want to solve. It doesn't
make any code easier to read if you have to convert every constant to
a rank-0 float array. If I get an ingenious idea for solving this
problem, I'll let you know immediately...

Konrad Hinsen                     | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie             | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal            | Fax:  +1-514-343-7586
C.P. 6128, succ. Centre-Ville     | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7             | Francais (phase experimentale)

MATRIX-SIG  - SIG on Matrix Math for Python

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