[PYTHON MATRIX-SIG] Type coercion two more times
Hinsen Konrad
hinsenk@ere.umontreal.ca
Fri, 26 Jan 1996 10:51:15 -0500
Maybe, but it seems like we're trying to satisfy two conflicting
constraints, namely,
1) providing a nice, consistant array library usable for the
mathematically oriented (potential) Python user, and
2) providing easy access to custom, relatively low level number
crunching and control of C types, i.e. 16 bit speech data, 8 bit
images, etc.
You seem to imply that the additional types will be used only by
people in group 2. But I expect that C floats will also be used by
ordinary mathematically oriented Python users, whenever memory
or CPU time are more important than accuracy. Most of my numerical
programs (mostly in Fortran) use both precisions, so why should
Python code be different?
I see. Yes, the question of whether or not to to convert scalars is
pivotal. If someone is using a type other than a Python numeric
type, then doesn't that mean they are willing to accept the loss of
precision? If you have an array_f, do you expect calculations with
Sometimes. There are two situations where I expect problems:
1) Someone uses a library written by someone else, and this
library uses C floats. The user of this library may not be
aware of this, or might not care. Until he experiences a
mysterious loss of precision in his code...
2) Someone wants to use both precisions, and either forgets
about the coercion problems, or expects them to be like in
all other languages (which coerce float->double, but not
the reverse).
Therefore I consider Jim's first proposal (no coercion between
float and double) still the best: those who want both precisions
and do everything correctly get what they want, and those who
make a mistake or have misunderstood the rules get an exception.
I'd rather be surprised by an exception than by loss of precision.
-------------------------------------------------------------------------------
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
=================